bnegrao / shell_map

A HashMap "object" made in bash 3
Apache License 2.0
19 stars 3 forks source link

grep -P not available #1

Open folkvir opened 5 years ago

folkvir commented 5 years ago

workaround change grep -Po to grep -o

xdhmoore commented 4 years ago

So, I did this a while ago, but I made the following change as a workaround. I'm not 100% sure this is exactly the same, but it has worked well enough for me:

keys)
    #declare | grep -Po "(?<=${FUNCNAME}_DATA_)\w+((?=\=))"
    declare | grep -E "${FUNCNAME}_DATA_[[:alnum:]_]+=" | sed -E "s/${FUNCNAME}_DATA_([[:alnum:]_]+)=.*/\1/g"
;;
rbtylee commented 3 months ago

declare | grep -o "${FUNCNAME}_DATA_[^=]*" | sed "s/^${FUNCNAME}_DATA_//"

Works for me tested on Ubuntu 22.04:

./test_shell_map.sh All tests were successful