0

I would like to concatenate multiple parameters to a single string in bash like this:

$ ls -latr
$ cp -Rv directory1 directory2

The best I can do is something like this:

while (( ${#} ))
do
    case "${1}" in
        "-h" | "--help")
            getScriptUsage
            exit 0
            ;;

        "-i" | "--include-alpha-builds")
            include_alpha_build_versions="true"
            ;;

        "-r" | "--redownload")
            removeAllFiles
            ;;

        "-t" | "--torbrowser-version")
            tarball_filename_version="${2}"
            shift
            ;;

        "-v" | "--version")
            getVersion
            ;;

        *)
            getScriptUsage
            /bin/echo -e "\e[01;31mParameter '${1}' not found.\e[0m"
            exit 1
    esac

    shift || break
done

Source

But with that, I can only append the parameters:

$ torbrowser -i -r -t 9.5

Might be off topic: I also would like to be able to mix parameters around, like in cp:

$ cp directory1 directory2 -Rv
$ cp -Rv directory1 directory2
Benjamin W.
  • 46,058
  • 19
  • 106
  • 116

0 Answers0