nodejs-disks icon indicating copy to clipboard operation
nodejs-disks copied to clipboard

On OS X (I suppose on linux too) returns wrong mount point if space used in drive's name

Open kloneets opened this issue 9 years ago • 7 comments

If, for example, my drive name would be some data, then nodejs-disks interprets mount point as /Volumes/some. This happens because mount point searching algorithm prints with awk 6th parameter. I suggest (it is my quick and dirty hack because I do not know awk) replacing this line 'df | grep ' + drive + ' | awk \'{print $6}\'' with this 'df | grep ' + drive + ' | grep -oh \' /.*\' | grep -oh \'/.*\''

kloneets avatar Mar 30 '16 10:03 kloneets

Ok, I looked closer to code and se, that trimming is performed afterwords with javascript, so, line could be just: 'df | grep ' + drive + ' | grep -oh \' /.*\''

kloneets avatar Mar 30 '16 10:03 kloneets

Yeah. I've run into this as well. (Check out my fork.) I switched it with this: 'df -kl | grep ' + drive + ' | awk '{ for (i = 9; i <= NF; i++) print $i}' ORS=' '' Not the best because it assumes that the 9th is the beginning of the mount point. What if the first parameter has a space in it? What does yours do?

jssuttles avatar May 03 '16 14:05 jssuttles

Mine just finds row with drive and asumes that / will be last param with "/" (slash), which will be the mount point. So - it returns everything from this /. Extra space will be trimmed by javascript.

kloneets avatar May 03 '16 17:05 kloneets

Does that get "/Volumes/some drive"?

jssuttles avatar May 03 '16 17:05 jssuttles

In my case it did :D

kloneets avatar May 03 '16 17:05 kloneets

A case where that would fail is if the mount point folder has a trailing space ('/Volumes /some drive'). I think that's less possible than the first field having a space in it. So, it's a better solution than mine. Do you know if it's possible?

jssuttles avatar May 03 '16 18:05 jssuttles

Never saw such mountpoint naming, but users are geniuses and, if someone allows to do this, they will :D I just tested on my mac (el capitan) and my solution worked on flahsdrive called " My flash " (space before "My" and after "flash"). So - need to be tested on other platforms :)

kloneets avatar May 04 '16 06:05 kloneets