<p>Unfortunately, expansion *is* performed by the remote shell, which is why your shell quoting approach works (and is necessary). �There's really no way around this, since the ssh client simply joins all of its trailing arguments with spaces and sends this single string to the ssh server, which exec()s $SHELL -c <string>.</p>
<div class="gmail_quote">On Nov 18, 2010 4:09 PM, "Michal Sojka" <<a href="mailto:sojkam1@fel.cvut.cz" target="_blank">sojkam1@fel.cvut.cz</a>> wrote:<br type="attribution">> On Wed, 10 Nov 2010, Mark Walters wrote:<br>
>> I am experimenting with using notmuch remotely over ssh (as in the<br>>> NEWS file; i.e. with a script containing ssh user@host notmuch "$@")<br>>> This is mostly excellent but it seems to get confused by some queries.<br>
>> For example those containing brackets or just consisting of *. I think<br>>> this is a problem with ssh spawning a shell on the remote machine<br>>> which doesn't like the brackets or *.<br>>> <br>
>> Explicitly to reproduce the problem start notmuch with a remote<br>>> database using a script as above;<br>>> type * in the search box;<br>>> and emacs shows:<br>>> End of search results. (process returned 1)<br>
> <br>> Hi Mark,<br>> <br>> you are right, that there are problems with the queries containing shell<br>> meta characters. AFAIK the probelm is not caused by the remote shell, as<br>> notmuch is there invoked directly by ssh, but by the shell invoking the<br>
> ssh. I do not know precisely why, but the following script seems to work<br>> correctly even for the queries containing shell meta characters. It uses<br>> bash's printf extension to print shell-quoted version of a string.<br>
> <br>> #!/bin/bash<br>> printf -v args "%q " "$@"<br>> ssh <a href="http://example.org" target="_blank">example.org</a> notmuch $args<br>> <br>> -Michal<br>> _______________________________________________<br>
> notmuch mailing list<br>> <a href="mailto:notmuch@notmuchmail.org" target="_blank">notmuch@notmuchmail.org</a><br>> <a href="http://notmuchmail.org/mailman/listinfo/notmuch" target="_blank">http://notmuchmail.org/mailman/listinfo/notmuch</a><br>
</div>