Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using the windows port of bash known as win-bash, and based on what it says about paths:

One important difference is the handling of drives: cygwin uses its installation directory as root dir and links all drives in the pseudo subdir /cygdrive. win-bash uses a diffent method: drives are included in paths, like on windows (e.g. c:/Winnt/System32). The root directory / is mapped to the root directory of the current drive. Examples: ls c:/winnt - shows the content of the directory c:/winnt cd c:/; ls /winnt - changes current drive to c: and shows the content of the directory c:/winnt cd d:/; ls /winnt- changes current drive to d: and shows the content of the directory d:/winnt There are some other differences, most of them have been added to simplify the usage of existing un*x shell scripts: If a shell script starts with an interpreter specification like #!/path/interpreter, the interpreter is searched in the PATH environment instead of /path. E.g. a Perl script starting with #!/bin/perl will be started with perl.exe from the PATH environment variable. win-bash doesn't use any dlls or registry keys

Detecting non-root paths seem to work such as: if [ -d "C:/bash" ]; then echo "yes"; else echo "no"; fi However, detecting root paths like so if [ -d "C:/" ]; then echo "yes"; else echo "no"; fi does not work. This also includes C: and /.

Perhaps there is another syntax bash scripting syntax to detect the existence of paths?

share|improve this question
    
Do C:/. and C:/bash/.. work? –  ignis Apr 27 '13 at 13:38
    
It does! Thanks! –  chaz Apr 27 '13 at 17:24
    
Okay, I'll turn that into an answer. –  ignis Apr 27 '13 at 17:32

3 Answers 3

I found that adding a period after the root drive path works as suggested by ignis.

share|improve this answer

Workaround: do C:/. and C:/bash/.. work?

share|improve this answer

An alternative to win-bash would be winbash from here. It did a better job at detecting root paths. Both "C:/" and "/" return yes on the tests. Only "C:" failed.

Plus I like that winbash handles the familiar ctrl-key combos we're used to like ctrl-p, ctrl-a, ctrl-e, etc. (in win-bash it just returns "^P" on the screen).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.