Skip to main content
added 62 characters in body
Source Link
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441

The Proper Way for storing arbitrary commands or arguments in a variable would be to use an array, see How can we run a command stored in a variable?

But you can just tell shellcheck you like it just the way it is, as long as you're sure it's ok (i.e. you don't have whitespace that should stay intact, or glob characters that could cause issues, and didn't change IFS to something that would trash this):

AREA_ARG=""
if __SOME_SETTING__ ; then
  AREA_ARG=" --area us,ca "
fi


# shellcheck disable=SC2086 # split on purpose
process_data -i /some/path $AREA_ARG

See https://www.shellcheck.net/wiki/Directive

The Proper Way for storing arbitrary commands or arguments in a variable would be to use an array, see How can we run a command stored in a variable?

But you can just tell shellcheck you like it just the way it is, as long as you're sure it's ok (i.e. you don't have whitespace that should stay intact, or glob characters that could cause issues):

AREA_ARG=""
if __SOME_SETTING__ ; then
  AREA_ARG=" --area us,ca "
fi


# shellcheck disable=SC2086 # split on purpose
process_data -i /some/path $AREA_ARG

See https://www.shellcheck.net/wiki/Directive

The Proper Way for storing arbitrary commands or arguments in a variable would be to use an array, see How can we run a command stored in a variable?

But you can just tell shellcheck you like it just the way it is, as long as you're sure it's ok (i.e. you don't have whitespace that should stay intact, or glob characters that could cause issues, and didn't change IFS to something that would trash this):

AREA_ARG=""
if __SOME_SETTING__ ; then
  AREA_ARG=" --area us,ca "
fi


# shellcheck disable=SC2086 # split on purpose
process_data -i /some/path $AREA_ARG

See https://www.shellcheck.net/wiki/Directive

added 64 characters in body
Source Link
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441

The Proper Way for storing arbitrary commands or arguments in a variable would be to use an array, see How can we run a command stored in a variable?

But you can just tell shellcheck you like it just the way it is, as long as you knowyou're sure it's ok (i.e. you don't have whitespace that should stay intact, or glob characters that could cause issues):

AREA_ARG=""
if __SOME_SETTING__ ; then
  AREA_ARG=" --area us,ca "
fi 


# split on purpose, $AREA_ARG can't containshellcheck globdisable=SC2086 characters
# shellchecksplit disable=SC2086on purpose
process_data -i /some/path $AREA_ARG

See https://www.shellcheck.net/wiki/Directive

The Proper Way for storing arbitrary commands or arguments in a variable would be to use an array, see How can we run a command stored in a variable?

But you can just tell shellcheck you like it just the way it is, as long as you know it's ok:

AREA_ARG=""
if __SOME_SETTING__ ; then
  AREA_ARG=" --area us,ca "
fi

# split on purpose, $AREA_ARG can't contain glob characters
# shellcheck disable=SC2086
process_data -i /some/path $AREA_ARG

See https://www.shellcheck.net/wiki/Directive

The Proper Way for storing arbitrary commands or arguments in a variable would be to use an array, see How can we run a command stored in a variable?

But you can just tell shellcheck you like it just the way it is, as long as you're sure it's ok (i.e. you don't have whitespace that should stay intact, or glob characters that could cause issues):

AREA_ARG=""
if __SOME_SETTING__ ; then
  AREA_ARG=" --area us,ca "
fi 


# shellcheck disable=SC2086 # split on purpose
process_data -i /some/path $AREA_ARG

See https://www.shellcheck.net/wiki/Directive

Source Link
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441

The Proper Way for storing arbitrary commands or arguments in a variable would be to use an array, see How can we run a command stored in a variable?

But you can just tell shellcheck you like it just the way it is, as long as you know it's ok:

AREA_ARG=""
if __SOME_SETTING__ ; then
  AREA_ARG=" --area us,ca "
fi

# split on purpose, $AREA_ARG can't contain glob characters
# shellcheck disable=SC2086
process_data -i /some/path $AREA_ARG

See https://www.shellcheck.net/wiki/Directive