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
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";
}
{
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
}
# 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
--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