shithub: x

Download patch

ref: 71ccea101ceabe1fa01ae111434bbdb55f07a201
parent: 15a47f5bcfdb3a1059c3dcea51786ce1ac40abf4
author: kvik <[email protected]>
date: Sun Nov 10 12:01:55 EST 2019

x/run: feed the commands to remote host over ssh stdin

Previously we'd bother invoking $SHELL -c and passing the escaped
command line as an argument, which was complex to implement and
inflexible.

We can instead construct a proper script and feed it over pipe to
remote shell, which is easy to implement and is far more flexible.
It has also provided an opportunity to enable the following:

	cat <<. | x/run
	echo not bad
	.

--- a/run
+++ b/run
@@ -7,9 +7,11 @@
 }
 if(~ $1 --)
 	shift
-rpath=`{x/path -P}
-cmd=`{awk 'BEGIN{
-	printf("$SHELL %s -c ''cd %s; %s''",
-		ENVIRON["flags"], ENVIRON["rpath"], ENVIRON["*"])
-}'}
-ssh `{x/path -l} $"cmd
+
+{
+	echo cd `{x/path -P}
+	if(! grep -s '/dev/cons' /fd/0ctl)
+		cat
+	if not
+		echo $"*
+}| ssh $flags `{x/path -l}