Add hostname "lh" as a --no-cd localhost.
authorWayne Davison <wayne@opencoder.net>
Thu, 4 Jun 2020 19:37:07 +0000 (12:37 -0700)
committerWayne Davison <wayne@opencoder.net>
Thu, 4 Jun 2020 19:58:02 +0000 (12:58 -0700)
rsync.yo
support/lsh
support/lsh.sh

index dfcda72b3460d00e98f0a2452998d4d0b132be0b..b62bda8d71f02d8c6fe76d825a57c5b43d8566f6 100644 (file)
--- a/rsync.yo
+++ b/rsync.yo
@@ -1910,11 +1910,12 @@ is not specified then the user's default groups are used.
 
 The option only affects one side of the transfer unless the transfer is local,
 in which case it affects both sides. Use the bf(--remote-option) to affect the
-remote side, such as bf(-M--copy-as=joe). For a local transfer, the "lsh"
+remote side, such as bf(-M--copy-as=joe). For a local transfer, the lsh (or lsh.sh)
 support file provides a local-shell helper script that can be used to allow a
-"localhost:" host-spec to be specified without needing to setup any remote
-shells (allowing you to specify remote options that affect the side of the
-transfer that is using the host-spec, and local options for the other side).
+"localhost:" or "lh:" host-spec to be specified without needing to setup any
+remote shells, allowing you to specify remote options that affect the side of
+the transfer that is using the host-spec (and using hostname "lh" avoids the
+overriding of the remote directory to the user's home dir).
 
 This option can help to reduce the risk of an rsync being run as root into or
 out of a directory that might have live changes happening to it and you want to
index 2f64d311c504def0f213637988b3bf4f9cf83569..81a593b64ac58aad63df63f7e02b8decc0d9ccd2 100755 (executable)
@@ -26,7 +26,9 @@ my $host = shift;
 if ($host =~ s/^([^@]+)\@//) {
     $login_name = $1;
 }
-if ($host ne 'localhost') {
+if ($host eq 'lh') {
+    $no_chdir = 1;
+} elsif ($host ne 'localhost') {
     die "lsh: unable to connect to host $host\n";
 }
 
@@ -77,5 +79,8 @@ sub usage
 {
     die <<EOT;
 Usage: lsh [-l user] [--sudo] [--no-cd] localhost COMMAND [...]
+
+Note that if you pass hostname "lh" instead of "localhost" that
+the --no-cd option is implied.
 EOT
 }
index b63444e33b474a8d984531007b46e2c53d0be38a..f74a8ef48c0f1fd446bfa7103eefe115fa7970ac 100755 (executable)
@@ -7,7 +7,7 @@
 # command.
 
 user=''
-do_cd=y # Default path is user's home dir, just like ssh.
+do_cd=y # Default path is user's home dir (just like ssh) unless host is "lh".
 
 while : ; do
     case "$1" in
@@ -16,6 +16,7 @@ while : ; do
     --no-cd) do_cd=n; shift ;;
     -*) shift ;;
     localhost) shift; break ;;
+    lh) do_cd=n; shift; break ;;
     *) echo "lsh: unable to connect to host $1" 1>&2; exit 1 ;;
     esac
 done