Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- # Initially, I was trying to have my filter function return both the flag and the flag's values.
- # As you can see below, my value substring contained spaces, which led to the following two outcomes:
- # 1) If the command is not quoted, the shell parses the output and splits the string into 4 words
- # 2) If the command is quoted, word splitting is avoided and you get 1 word
- # In both cases, the ffmpeg utility would fail since it's not passed valid options.
- filter_flag_and_value() {
- echo "-filter_complex first second third"
- }
- filter_value() {
- echo "first second third"
- }
- parameter_info() {
- printf "Num args: %d\n" $#
- printf "<%s> " "$@"
- printf "\n"
- }
- # 4 positional parameters due to wordsplitting by the shell
- parameter_info $(filter_flag_and_value)
- # I don't think it's possible to have one function return both the flag and the value as 2 parameters.
- parameter_info "$(filter_flag_and_value)"
- # 2 positional parameters
- parameter_info "-filter_complex" "first second third"
- # 2 positional parameters since the result of the command substitution is not split thanks to the quotations
- parameter_info "-filter_complex" "$(filter_value)"
Add Comment
Please, Sign In to add comment