/dev/stdin...

This commit is contained in:
pvincent
2026-08-13 21:43:49 +04:00
parent 530f42bbf8
commit 30658cc495
3 changed files with 27 additions and 11 deletions
+24 -9
View File
@@ -623,9 +623,16 @@ function usage {
}
function parse_options {
[[ $# == 0 ]] && >&2 echo 'ERROR: script expected!' && builtin exit 2
if [[ $# == 1 ]]; then
HEREDOC=false
if [[ $# == 0 ]]; then
if [[ -t 0 ]]; then
>&2 echo 'ERROR: script expected!'
builtin exit 2
else
HEREDOC=true
return
fi
elif [[ $# == 1 ]]; then
case "$1" in
--help) usage && builtin exit ;;
--version) cat "${MIAOU_BASH_DIR:-/opt/miaou-bash}/.semver_git_tag" && builtin exit ;;
@@ -646,10 +653,12 @@ function parse_options {
fi
[[ $1 =~ ^- ]] && >&2 echo "ERROR: too many args $#, either single option or SCRIPT + args accepted!" && builtin exit 2
SCRIPT="$1"
[[ ! -v SCRIPT ]] && >&2 echo 'ERROR: script expected!' && builtin exit 2
[[ ! -f "$SCRIPT" ]] && >&2 echo "ERROR: script '$SCRIPT' not found!" && builtin exit 2
true
if [[ ! -f "$SCRIPT" ]]; then
>&2 echo "ERROR: script '$SCRIPT' not found!"
builtin exit 3
fi
}
function read {
@@ -670,7 +679,8 @@ trap 'on_exit $?' EXIT
trap 'on_pipe' PIPE
trap 'on_return' RETURN
BASH_ARGV0="$SCRIPT" && shift
[[ -v SCRIPT ]] && BASH_ARGV0="${SCRIPT}" && shift
if is_true "$CHILD_PROCESS"; then
# any nested children
exec 4>/dev/tty 2>"$MIAOU_BASH_ERROR"
@@ -688,5 +698,10 @@ else
miaou_debug "<main file=$BASH_ARGV0 pid=${BASHPID}/>"
fi
# shellcheck source=/dev/null
source "$SCRIPT"
if [[ "$HEREDOC" == true ]]; then
# shellcheck source=/dev/stdin
source /dev/stdin
else
# shellcheck source=/dev/null
source "$SCRIPT"
fi
+1 -1
View File
@@ -139,7 +139,7 @@ time {
fail_stderr_count unbound_variable 1
fail_stderr_count child_error 4
fail_miaou_count command_error_multiline 6
fail_miaou_count command_error_multiline 7
}
failed=${#failures[@]}
success=$((test_count - failed))
+2 -1
View File
@@ -13,8 +13,9 @@ function do_subshell_false {
}
function do_command_error_multiline {
miaou-bash <<EOF
source /dev/stdin <<EOF
echo ok
echo yop
false
echo SHOULD NOT APPEAR
EOF