0

I need to Concatenat string with leading dash in multiple choice to variable, but it doesn't work as expected and I don't know what is the problem

#!/bin/bash

filterOptionsStr="" PS3='Filter Options: ' options=("Filter HTTP status codes from response" "skip/quit") select option in "${options[@]}"; do case $option in "Filter HTTP status codes from response")

    echo $option
    read -ep "Status codes: " status_codes

    filterOptionsStr+=  "-fc ${status_codes} "
    echo $filterOptionsStr
    ;;    

    "skip/quit")
    break
    ;;
esac

done

output:

└─$ ./test                                                                                                         130 ⨯
1) Filter HTTP status codes from response
2) skip/quit
Filter Options: 1
Filter HTTP status codes from response
Status codes: 301
./test: line 16: -fc 301: command not found

Filter Options: 1 Filter HTTP status codes from response Status codes: 404 ./test: line 16: -fc 404: command not found

Filter Options:

0 Answers0