Hello! Some time before I proposed idea for mv to leave symlink behind. It received neither approval nor disappoval, so here is patch.
Words are wind, so code should attract more attention ;)
--
Best regards,
Dmitry Bogatov <[email protected]>, GNU Thales maintainer.
GPG: D1E0591E0037BDCCBEE56002788BE01254B7F00D
Please, use GPG encryption, signing and format plain text letters
in accordance with RFC1855, section 2.1.1.
diff --git a/src/mv.c b/src/mv.c
index 5b08fdd..ff47e13 100644
--- a/src/mv.c
+++ b/src/mv.c
@@ -61,6 +61,7 @@ static struct option const long_options[] =
{"no-target-directory", no_argument, NULL, 'T'},
{"strip-trailing-slashes", no_argument, NULL, STRIP_TRAILING_SLASHES_OPTION},
{"suffix", required_argument, NULL, 'S'},
+ {"symbolic-trail", no_argument, NULL, 's'},
{"target-directory", required_argument, NULL, 't'},
{"update", no_argument, NULL, 'u'},
{"verbose", no_argument, NULL, 'v'},
@@ -236,6 +237,9 @@ do_move (const char *source, const char *dest, const struct
cp_options *x)
}
}
+ if (x->symbolic_link)
+ ok &= !!symlink(dest, source);
+
return ok;
}
@@ -301,6 +305,7 @@ Mandatory arguments to long options are mandatory for short
options too.\n\
\n\
-b like --backup but does not accept an argument\n\
-f, --force do not prompt before overwriting\n\
+ -s, --symbolic-trace leave a symbolic link to new file location.\n\
-i, --interactive prompt before overwrite\n\
-n, --no-clobber do not overwrite an existing file\n\
If you specify more than one of -i, -f, -n, only the final one takes effect.\n\
@@ -369,7 +374,7 @@ main (int argc, char **argv)
we'll actually use backup_suffix_string. */
backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
- while ((c = getopt_long (argc, argv, "bfint:uvS:T", long_options, NULL))
+ while ((c = getopt_long (argc, argv, "bfint:uvsS:T", long_options, NULL))
!= -1)
{
switch (c)
@@ -405,6 +410,9 @@ main (int argc, char **argv)
}
target_directory = optarg;
break;
+ case 's':
+ x.symbolic_link = true;
+ break;
case 'T':
no_target_directory = true;
break;
pgpMukhqvPrRk.pgp
Description: PGP signature
