diff options
author | Rob Landley <rob@landley.net> | 2018-04-08 20:50:10 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2018-04-08 20:50:10 -0500 |
commit | cd3f81ebe5c82f1fd5f610b0f2e0fa07ac27903e (patch) | |
tree | 68b7f7729971aed2e43ae0f1dbdecd7bba3c97b4 /toys/other | |
parent | 4f81242e384930a683b3591bc5a634fa22dda8ca (diff) | |
download | toybox-cd3f81ebe5c82f1fd5f610b0f2e0fa07ac27903e.tar.gz |
Add readlink -m to show where a missing path would be.
Note: ubuntu will show -m through a file, this treat that as error.
Diffstat (limited to 'toys/other')
-rw-r--r-- | toys/other/readlink.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/toys/other/readlink.c b/toys/other/readlink.c index fecd1ef8..2e0cf11e 100644 --- a/toys/other/readlink.c +++ b/toys/other/readlink.c @@ -2,7 +2,7 @@ * * Copyright 2007 Rob Landley <rob@landley.net> -USE_READLINK(NEWTOY(readlink, "<1>1fenq[-fe]", TOYFLAG_USR|TOYFLAG_BIN)) +USE_READLINK(NEWTOY(readlink, "<1>1nqmef[-mef]", TOYFLAG_USR|TOYFLAG_BIN)) config READLINK bool "readlink" @@ -16,6 +16,7 @@ config READLINK -e cannonical path to existing entry (fail if missing) -f full path (fail if directory missing) + -m ignore missing entries, show where it would be -n no trailing newline -q quiet (no output, just error code) */ @@ -28,9 +29,9 @@ void readlink_main(void) char *s; // Calculating full cannonical path? - - if (toys.optflags & (FLAG_f|FLAG_e)) - s = xabspath(*toys.optargs, toys.optflags & FLAG_e); + // Take advantage of flag positions to calculate m = -1, f = 0, e = 1 + if (toys.optflags & (FLAG_f|FLAG_e|FLAG_m)) + s = xabspath(*toys.optargs, (toys.optflags&(FLAG_f|FLAG_e))-1); else s = xreadlink(*toys.optargs); if (s) { |