Skip to content

Instantly share code, notes, and snippets.

@jmlich
Created February 14, 2022 15:08
Show Gist options
  • Save jmlich/e0408b8c6eeef79f9555bbbb34a989db to your computer and use it in GitHub Desktop.
Save jmlich/e0408b8c6eeef79f9555bbbb34a989db to your computer and use it in GitHub Desktop.
Hey bash: Is my array wrong?
#!/bin/bash
bash --version
echo ""
echo ""
declare -A parse_data=( \
['http://user:pass@www.example.com:19741/dir1/dir2/file.php?param=some_value&array[0]="123"&param2=\`cat /etc/passwd\`#bottom-left']='declare -a parsed='\''([0]="http" [1]="user" [2]="pass" [3]="www.example.com:19741")'\' \
)
for url in "${!parse_data[@]}"; do
ref="${parse_data[$url]}"
echo "url=$url"
echo "ref=$ref"
done
exit 0
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
url=http://user:pass@www.example.com:19741/dir1/dir2/file.php?param=some_value&array[0
ref="123"&param2=\`cat /etc/passwd\`#bottom-left]=declare -a parsed='([0]="http" [1]="user" [2]="pass" [3]="www.example.com:19741")'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment