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.


error () {
# <error code> <name> <string> <args>
local err="$1"
local name="$2"
local fmt="$3"
shift; shift; shift
    (echo "E: $name"
    for x in "$@"; do echo "EA: $x"; done
    echo "EF: $fmt") >&4
    (printf "E: $fmt\n" "$@") >&4
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.


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.