[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Should this be this way?
From: |
Pierre Gaston |
Subject: |
Re: Should this be this way? |
Date: |
Tue, 26 Feb 2013 07:41:32 +0200 |
On Tue, Feb 26, 2013 at 3:03 AM, Linda Walsh <bash@tlinx.org> wrote:
> My login shell is /bin/bash (i.e. not /bin/sh); SHELL=/bin/bash as well.
> Typing 'which bash' gives /bin/bash, and whence bash: bash is /bin/bash.
>
> I had the foll0wing script which acts differently based on
> whether or not it has a #!/bin/bash at the top: (i.e., as it is
> displayed below, it fails; one need remove the [] from the first
> line for it to work.
> ================
> #[!/bin/bash]
> while read fn;do
> base=${fn%.*}
> if [[ -e $base ]]; then
> if [[ $base -ot $fn ]]; then echo "compressed version ($fn) seems newer"
> elif [[ $base -nt $fn ]]; then echo "uncompressed version ($base)
> seem newer"
> else echo "both versions ($base) are same age"
> fi
> else
> echo "No uncompressed version of $base exists"
> fi
> done < <(find . -type f -name \*.[0-9].\*[zZ]\* )
> -------------
> The error:
> ./manscan.sh: line 12: syntax error near unexpected token `<'
> ./manscan.sh: line 12: `done < <(find . -type f -name \*.[0-9].\*[zZ]\* )'
>
> Why would this script behave differently if the first line
> exists or not? (Putting the !shell in square brackets,
> made it a comment, not an interpreter spec, thus the same
> effect as if it wasn't there ('cept the line number of the error is 1
> less if you don't have the line! ;-)).
>
> So...is this correct behavior for some[inane POSIX] reason?
> Seems a bit odd to me.
>
I don't seem to be able to reproduce it with my default configuration.
However I can reproduce it by setting (but not exporting) POSIXLY_CORRECT
- Re: Should this be this way?, (continued)
- Re: Should this be this way?, Linda Walsh, 2013/02/27
- Re: Should this be this way?, Chris Down, 2013/02/27
- Re: Should this be this way?, Chet Ramey, 2013/02/28
- Re: Should this be this way?, Bob Proulx, 2013/02/28
- Re: Should this be this way?, Andreas Schwab, 2013/02/28
- Re: Should this be this way?, Pierre Gaston, 2013/02/28
- Re: Should this be this way?, Sven Mascheck, 2013/02/28
- Re: Should this be this way?, Linda Walsh, 2013/02/28
- Re: Should this be this way?, Chet Ramey, 2013/02/26
- Re: Should this be this way?, Linda Walsh, 2013/02/27
Re: Should this be this way?,
Pierre Gaston <=
Re: Should this be this way?, Roman Rakus, 2013/02/26