On 25 October 2007 17:52, Ramon Felciano wrote: > Specifically, shell scripts don't appear to be able to read files based > on filenames passed in as commandline parameters.
Heh. Actually, shell scripts are entirely able to read files, based on any filename you pass in whatsoever - ... > [EMAIL PROTECTED] /cygdrive/c/Downloads > $ ./buggy.sh /cygdrive/c/Downloads/ramon.txt > Hello /cygdrive/c/Downloads/ramon.txt >> No such file or directoryramon.txt > Bye! > > [EMAIL PROTECTED] /cygdrive/c/Downloads ... - even filenames with a CR in them. And bash correctly reports that you do not have a file called "cygdrive/c/Downloads/ramon.txt^M" on your disk, although that ^M (CR with no LF) causes the error message to overwrite itself a bit. > There are no spaces in the filename and I'm using POSIX paths, so I > don't think that's the issue. I can clearly find and view the file from > the commandline so I don't think it is an access control or volume mount > problem in the Cygwin environment. The shell script itself sees the > command-line parameter (echo works) but the subsequent cat command fails > with a "No such file or directory" error. The thing that looks > particular odd is the error message: > > ---------------------------------------------------- >> No such file or directoryramon.txt > ---------------------------------------------------- > > which looks like it is an error message that overwrote the > "/cygdrive/c/Downloads/ramon.txt" pathname. CR at the end. That's the definitive symptom. > Any suggestions on where to hunt further for a resolution? Where did the CR actually come from? It came from here: $ cat buggy.sh #!/bin/sh echo Hello "$@" cat "$@" ^^^^^ If you've got CRLF lineendings in that script, that line actually looks bash (which, being unixy, only expects LF line endings) like this: cat "$@"^M<end-of-line> so once $@ is substituted (and quote removal applied), you have: cat /cygdrive/c/Downloads/ramon.txt^M The solution is to run d2u on buggy.sh, or don't use notepad/wordpad to create it, use vi/emacs/any other editor that can generate LF-only line endings. Also, see any of the recent release ANNOUNCEments in the cygwin-announce list archive for a couple of other options (set -oo igncr etc.). cheers, DaveK -- Can't think of a witty .sigline today.... -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/