Does qvm-run filter specific chars needed for bash scripts, like $@?

Does anybody know, why following does not work from dom0?

test() { qvm-run -q myqube "echo $@ > /home/user/foo"; }
test hello world

Whereas first storing arguments $@ in a variable does work:

test() { args="$@"; qvm-run -q myqube "echo $args > /home/user/foo"; }
test hello world

Is it some sort of escape filtering of the @ char in $@?
Shouldn’t $@ have already been replaced by dom0 terminal, before doing RPC stuff and filtering chars?

It works for me. Tried with AppVM based on debian-11 template.

UPD:
It works if you use quotes:

test "hello world"

And it’s unrelated to qvm-run. It’ll be the same for:

test() { bash -c "echo $@ > /home/user/foo"; }
test hello world

This one will work instead:

test() { bash -c "echo $* > /home/user/foo"; }
test hello world
$ test() { set -x; bash -c "echo $@ > /home/user/foo"; set +x; }
$ test asdasd3223 adssdasdsd33123fsfsdd
+ bash -c 'echo asdasd3223' 'adssdasdsd33123fsfsdd > /home/user/foo'
asdasd3223
+ set +x
1 Like

This, thanks much for your help!

Indeed my bash knowledge failed me (once again :joy:) and the issue not Qubes-related.

After enabling set -x it becomes apparent, what … surprising … word splitting the shell does with $@.

I don’t fully understand the difference yet, but guess I need to do some refreshing research on $@ vs $*.

1 Like