0
Why would the following return a 1:
ssh -tt server_name "sudo grep 'something' /path/to/file || [ $? = 1 ]"
The command in double quotes when run directly on server_name returns 0. Why is the ssh command considered to have failed?
I have the key for the user set up on the remote server. So if I login as userA on serverA, I can simply do the following:
ssh -tt server_name
and login as userA on server_name. So, I know that is not the issue. Is it the -tt? The double quotes?
I see, thank you so much for schooling me on that! I literally just thought of removing the quotes before I saw this and it worked. So inverting the quotes prevents expansion of the $?? Is the fact that $? gets expanded in some documentation? I can't find it in the ssh man page. – Touch – 2018-12-13T22:12:14.537
@KingTouchstone It's the shell that expands
$?
, notssh
. – Kamil Maciorowski – 2018-12-13T22:12:59.753@KingTouchstone The most general documentation is here. This is what any POSIX compliant shell should obey.
– Kamil Maciorowski – 2018-12-13T22:17:33.407Thank you for clarifying. I have found the GNU documentation for bash where this is specified, 3.1.2.3 Double Quotes. It seems that using double quotes with grep -P does not affect the regex based on what I understand in that documentation. – Touch – 2018-12-13T22:25:43.243