-2

I am rewriting debootstrap to fit me and for education. Why "shift" command in interaction piece of code in "functions" file? There are not so many arguments sent to use "shift" and, as I know, function arguments are accessible only in function.

Example:

error () {
# <error code> <name> <string> <args>
local err="$1"
local name="$2"
local fmt="$3"
shift; shift; shift
if [ "$USE_DEBIANINSTALLER_INTERACTION" ]; then
    (echo "E: $name"
    for x in "$@"; do echo "EA: $x"; done
    echo "EF: $fmt") >&4
else
    (printf "E: $fmt\n" "$@") >&4
fi
exit $err
}
2

The three shifts remove the error code, name and string from the arguments so the rest of the arguments are conveniently in $@ for the for loop in line nine of the script.

Not the answer you're looking for? Browse other questions tagged or ask your own question.