Bug: bash -e misbehaves with several nested
Andrey Repin
anrdaemon@yandex.ru
Thu May 25 14:54:00 GMT 2017
Greetings, Pavel Fedin!
>> > Hello! I'd like to report a strange bug in 64-bit bash. The following script:
>> >
>> > ---- cut ---
>> > #/bin/bash -e
>> >
>> > DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
>> > echo Works: $DIR
>> > ---- cut ---
>> >
>> > Simply exits and produces no output (never reaches echo). The same script works perfectly
>> on 32 bits. Versions are the same:
>> >
>> > --- cut ---
>>
>> It works fine for me.
>>
>> $ ./prova.bash
>> Works: /tmp
> Huh, works here too, indeed. But there's one little thing. If you just
> copypasted this from my email, then you probably miss "#!"
> (there's just "#", since i retyped the header, and made a typo). And with
> this typo it really works for some reason. Could you make
> sure once again ?
> Apparently it has to do with -e switch.
I doubt that.
> + cat /home/anrdaemon/Documents/.sh/xx.sh
> #!/bin/bash -xe
>
> cat "$0"
> DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
> echo Works: $DIR
> +++ dirname /home/anrdaemon/Documents/.sh/xx.sh
> ++ cd /home/anrdaemon/Documents/.sh
> ++ pwd
> + DIR=/home/anrdaemon/Documents/.sh
> + echo Works: /home/anrdaemon/Documents/.sh
> Works: /home/anrdaemon/Documents/.sh
At the same time,
> #/bin/bash -xe
>
> cat "$0"
> DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
> echo Works: $DIR
> /home/anrdaemon/Documents/.sh/xx.sh: 4:
> /home/anrdaemon/Documents/.sh/xx.sh: Bad substitution
> Works: /home/anrdaemon/Documents/.sh
If you are wondering, what's going on, …
sh is not bash. For me. I guess, dash is a little more vocal about errors,
than bash.
--
With best regards,
Andrey Repin
Thursday, May 25, 2017 17:34:21
Sorry for my terrible english... РўТРРҐ&ц&ЖVТ&Wч'G3ў‡GGўтц7–wv–вж6цТч&ц&ЖVЧ2ж‡FЦАР¤dў‡GGўтц7–wv–вж6цТцfрР¤Fц7VЦVзFF–цгў‡GGўтц7–wv–вж6цТцFц72ж‡FЦАРҐVз7V'67&–&R–жfуў‡GGўтц7–wv–вж6цТцЦВт7Vз7V'67&–&RЧ6–ЧЖPР Р
More information about the Cygwin
mailing list