Sample Header Ad - 728x90

bash subshell execution behaves unexpectedly

0 votes
0 answers
38 views
I have a script which is supposed to fetch 2 URLs sequentially: #!/bin/bash wget_command='wget --restrict-file-names=unix https://www.example.com/{path1,path2}/ ' $($wget_command) echo $wget_command >> wget_commands.log results in this message: --2025-04-30 09:13:49-- https://www.example.com/%7Bpath1,path2%7D/ ^ the %7D is a problem ---------- Whereas, directly issuing: wget --restrict-file-names=unix https://www.example.com/{path1,path2}/ results in the expected fetches and messages: --2025-04-30 09:14:13-- https://www.example.com/path1/ ... --2025-04-30 09:14:14-- https://www.example.com/path2/ ---------- It feels like {path1,path2} is triggering an expansion/interpolation when $($wget_command) goes to use it but I am not sure how to verify nor avoid this problem.
Asked by MonkeyZeus (143 rep)
Apr 30, 2025, 01:30 PM