-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
}

closed as unclear what you're asking by countermode, GAD3R, HalosGhost, don_crissti, mdpc Nov 4 '16 at 19:50

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

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.