From cd3f81ebe5c82f1fd5f610b0f2e0fa07ac27903e Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 8 Apr 2018 20:50:10 -0500 Subject: Add readlink -m to show where a missing path would be. Note: ubuntu will show -m through a file, this treat that as error. --- toys/other/readlink.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'toys') 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 -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) { -- cgit v1.2.3