Control: forcemerge 777262 -1
Am 18.06.2016 um 01:09 schrieb Christoph Biedl:
> Package: dash
> Version: 0.5.8-2.2
> Severity: normal
>
> Dear Maintainer,
>
> There's a surprising behaviour in dash when sourcing an empty file
> after a failed (non-zero) if statement. Although I'm reluctant to use
> the "bug" word, it's at least very weird and does not happen in bash
> or zsh.
>
> Take that "main.sh" script, it sources an empty "source.sh", unless
> it's not there:
>
> ,------------------
> #!/bin/sh
> set -e
> S=./source.sh
> if [ ! -f "$S" ] ; then
> echo 'No file to source'
> else
> . "$S"
> fi
> echo 'Here we go'
> `------------------
>
> where source.sh:
> ,------------------
> # no op
> `------------------
>
> Now running "sh -x main.sh" results in
>
> | + set -e
> | + S=source.sh
> | + [ ! -f source.sh ]
> | + . source.sh
>
> and $? is set to 1.
>
> In other words, the "." statement is considered failing, hence aborting
> script execution.
>
> Using bash the execution continues:
>
> | (...)
> | + . source.sh
> | + echo 'Here we go'
> | Here we go
>
> and $? is zero. Same for zsh.
This has been fixed in dash 0.5.9.1. See #777262 and [1] for details.
Cheers,
Sven
1.
https://git.kernel.org/pub/scm/utils/dash/dash.git/commit/?id=17a5f24e0a8ec22f74399764db30d97ae310f3c6