Skip to main content
added 91 characters in body
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

You are getting bar in there because that's what $1 is after your shift operation before the loop.

To shift off two positional parameters, use shift 2. However, it may be safer to clear the list of positional parameters before the loop by replacing shift with set --. That way, you don't rely on the user supplying the correct number of parameters. Some shells would issue a diagnostic message if you tried to shift off more values than in the list, and if the user gives you too few or too many values, these would still be in "$@".

Also, consider usingyou will need to use set -- in place of plain set when setting positional parameters, both in this case and in general, to avoid accidentally setting shell options or, as in this case, invoking set with invalid options.

set -- "$@" --build-arg "$line"

You are getting bar in there because that's what $1 is after your shift operation before the loop.

To shift off two positional parameters, use shift 2. However, it may be safer to clear the list of positional parameters before the loop by replacing shift with set --. That way, you don't rely on the user supplying the correct number of parameters. Some shells would issue a diagnostic message if you tried to shift off more values than in the list, and if the user gives you too few or too many values, these would still be in "$@".

Also, consider using set -- in place of plain set when setting positional parameters, in general, to avoid accidentally setting shell options.

set -- "$@" --build-arg "$line"

You are getting bar in there because that's what $1 is after your shift operation before the loop.

To shift off two positional parameters, use shift 2. However, it may be safer to clear the list of positional parameters before the loop by replacing shift with set --. That way, you don't rely on the user supplying the correct number of parameters. Some shells would issue a diagnostic message if you tried to shift off more values than in the list, and if the user gives you too few or too many values, these would still be in "$@".

Also, you will need to use set -- in place of plain set when setting positional parameters, both in this case and in general, to avoid accidentally setting shell options or, as in this case, invoking set with invalid options.

set -- "$@" --build-arg "$line"
added 284 characters in body
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

You are getting bar in there because that's what $1 is after your shift operation before the loop. To

To shift off two positional parameters, use shift 2. AlternativelyHowever, it may be safer to clear the list of positional parameters before the loop by replacing shift with set --. That way, you don't rely on the user supplying the correct number of parameters. Some shells would issue a diagnostic message if you tried to shift off more values than in the list, and if the user gives you too few or too many values, these would still be in "$@".

Also, consider using set -- in place of plain set when setting positional parameters, in general, to avoid accidentally setting shell options.

set -- "$@" --build-arg "$line"

You are getting bar in there because that's what $1 is after your shift operation before the loop. To shift off two positional parameters, use shift 2. Alternatively, clear the list of positional parameters before the loop by replacing shift with set --.

Also, consider using set -- in place of plain set when setting positional parameters, in general, to avoid accidentally setting shell options.

set -- "$@" --build-arg "$line"

You are getting bar in there because that's what $1 is after your shift operation before the loop.

To shift off two positional parameters, use shift 2. However, it may be safer to clear the list of positional parameters before the loop by replacing shift with set --. That way, you don't rely on the user supplying the correct number of parameters. Some shells would issue a diagnostic message if you tried to shift off more values than in the list, and if the user gives you too few or too many values, these would still be in "$@".

Also, consider using set -- in place of plain set when setting positional parameters, in general, to avoid accidentally setting shell options.

set -- "$@" --build-arg "$line"
added 171 characters in body
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

You are getting bar in there because that's what $1 is after your shift operation before the loop. To shift off two positional parameters, use shift 2. Alternatively, clear the list of positional parameters before the loop by replacing shift with set --.

Also, consider using set -- in place of plain set when setting positional parameters, in general, to avoid accidentally setting shell options.

set -- "$@" --build-arg "$line"

You are getting bar in there because that's what $1 is after your shift operation before the loop. To shift off two positional parameters, use shift 2. Alternatively, clear the list of positional parameters before the loop by replacing shift with set --.

You are getting bar in there because that's what $1 is after your shift operation before the loop. To shift off two positional parameters, use shift 2. Alternatively, clear the list of positional parameters before the loop by replacing shift with set --.

Also, consider using set -- in place of plain set when setting positional parameters, in general, to avoid accidentally setting shell options.

set -- "$@" --build-arg "$line"
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k
Loading