Re: BASH in Cygwin and *nix
From: Larry I Smith (larryXiXsmith_at_verizon.net)
Date: 08/03/04
- Next message: Hanna Lord: "Re: BASH in Cygwin and *nix"
- Previous message: Hanna Lord: "BASH in Cygwin and *nix"
- In reply to: Hanna Lord: "BASH in Cygwin and *nix"
- Next in thread: Hanna Lord: "Re: BASH in Cygwin and *nix"
- Reply: Hanna Lord: "Re: BASH in Cygwin and *nix"
- Reply: Grant Edwards: "Re: BASH in Cygwin and *nix"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 03 Aug 2004 17:14:15 GMT
Hanna Lord wrote:
> Hi all,
> I have just tried to run a BASH script that was written on a Slackware 10
> box on Cygwin (just installed) and I get errors, do I need to do something
> additional to Cygwin or my scripts to make them Cygwin happy?
>
> ---- START OF SCRIPT ----
>
> #!/bin/bash
>
> # Check project path
> if [ ! -d $PROJECT_PATH ]; then
> echo "Error :: PROJECT_PATH environment variable not set or not valid."
> exit 1
> fi
>
> ---- END OF SCRIPT ----
>
> If you run this under Slackware its happy, but under Cygwin I get the
> following error:
> proj_shell: line3: [: /test_stuff: binary operator expected
>
> Many thanks
>
>
You must first check for an empty/undefined PROJECT_PATH
before checking for its existence on disk.
"[ ! -d $PROJECT_PATH ]" produces undefined behaviour if
PROJECT_PATH is empty (i.e. your results may vary between
sh/bash implementations). This should work everywhere:
if [ -z $PROJECT_PATH ] || [ ! -d $PROJECT_PATH ]; then
Regards,
Larry
-- Anti-spam address, change each 'X' to '.' to reply directly.
- Next message: Hanna Lord: "Re: BASH in Cygwin and *nix"
- Previous message: Hanna Lord: "BASH in Cygwin and *nix"
- In reply to: Hanna Lord: "BASH in Cygwin and *nix"
- Next in thread: Hanna Lord: "Re: BASH in Cygwin and *nix"
- Reply: Hanna Lord: "Re: BASH in Cygwin and *nix"
- Reply: Grant Edwards: "Re: BASH in Cygwin and *nix"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|