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: mkshortcut fails when run from setup, postinstall/ - not otherwise

On 12/20/2017 06:59 AM, Enrique Perez-Terron wrote:

So I have added a line "set -x" at the top in postinstall/, and the relevant section becomes

  + read target name desc
  + '[' -r ']'

(by the way -- this reveals another bug too: The script says "[ -r $t ] && $mks ..." where I am sure it should be "[ -r $target ] && $mks ...")

Or, rather,

[ -r "$target" ]

It is almost always a bug to use [ ] without quoting "$..." expansions, because if the expansion of $... is empty, it changes the number of arguments to [ and thus the test that [ performs.

If your script uses #!/bin/bash, then you can use bashisms like:

[[ -r $target ]]

which do the right thing ('[[' is part of the shell grammar, rather than treated like an executable; as such, you can safely omit quoting in that form; but '[[' is not yet POSIX and is not supported on dash).

(and again btw, I am not sure bash should count "[ -r ]" as a true statement)

I am. POSIX requires that behavior. Any time you have exactly one argument to '[', the result is true unless that argument was the empty string.

Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization: |

Problem reports:
Unsubscribe info:

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