function read 2>&1

This commit is contained in:
pvincent
2026-08-07 23:20:07 +04:00
parent 2c8c15d705
commit 109cf1947f
+6
View File
@@ -613,6 +613,7 @@ function usage {
function parse_options {
[[ $# == 0 ]] && >&2 echo 'ERROR: script expected!' && builtin exit 2
if [[ $# == 1 ]]; then
case "$1" in
--help) usage && builtin exit ;;
@@ -622,6 +623,7 @@ function parse_options {
-*) >&2 echo "ERROR: option '$1' unknown!" && usage && builtin exit 2 ;;
esac
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
@@ -629,6 +631,10 @@ function parse_options {
true
}
function read {
2>&1 builtin read "$@"
}
## main
set -euo pipefail