This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bash shell script issue


On 9/7/2016 1:27 PM, Andrey Repin wrote:

So "Insufficient quoting" means nothing to me. How should it be?

Put quotes around any variable expansion you are not in control of.

I was taking the example from a shell script I found.


So I added quoting on the echo:

#!/bin/bash
echo "$PWD"

Yes, that's helpful is PWD contains anything that bash might otherwise act on.

project_root=$PWD

But this is more important to change.  There is the \r issue already discussed,
but consider a path such as: Program Files (x86)
It has spaces and parentheses.  What you need to write (and I try to be careful
about this in all cygwin scripts!) is:

project_root="$PWD"

(I like:  project_root="${PWD}"  myself.)

x=${project_root}/tools

Similar change required.

Directories under Unix almost never contain spaces, so script writing there
typically does not deal with the strange characters, but they certainly
come up on Windows, and leak through to the Cygwin environment.

Regards -- Eliot Moss

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]