From fe91e68e8d1e6a2974b57a9855032ad94d137e8e Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 22 Nov 2012 21:18:09 -0600 Subject: Remove readlink -m for being poorly defined ("readlink -m /dev/null/and/more" answers what question, exactly?), rewrite xabspath() to work right and not depend on realpath, fix subtle longstanding bug in llist_traverse(). --- toys/other/readlink.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'toys/other') diff --git a/toys/other/readlink.c b/toys/other/readlink.c index b237a510..46855f10 100644 --- a/toys/other/readlink.c +++ b/toys/other/readlink.c @@ -2,7 +2,7 @@ * * Copyright 2007 Rob Landley -USE_READLINK(NEWTOY(readlink, "<1>1femnq[-fem]", TOYFLAG_BIN)) +USE_READLINK(NEWTOY(readlink, "<1>1fenq[-fe]", TOYFLAG_BIN)) config READLINK bool "readlink" @@ -14,9 +14,8 @@ config READLINK Options for producing cannonical paths (all symlinks/./.. resolved): - -e cannonical path to existing file (fail if does not exist) - -f cannonical path to creatable file (fail if directory does not exist) - -m cannonical path + -e cannonical path to existing entry (fail if nothing there) + -f full path (fail if location does not exist) -n no trailing newline -q quiet (no output, just error code) */ @@ -30,14 +29,9 @@ void readlink_main(void) // Calculating full cannonical path? - if (toys.optflags & (FLAG_f|FLAG_e|FLAG_m)) { - unsigned u = 0; - - if (toys.optflags & FLAG_f) u++; - if (toys.optflags & FLAG_m) u=999999999; - - s = xabspath(*toys.optargs, u); - } else s = xreadlink(*toys.optargs); + if (toys.optflags & (FLAG_f|FLAG_e)) + s = xabspath(*toys.optargs, toys.optflags & FLAG_e); + else s = xreadlink(*toys.optargs); if (s) { if (!(toys.optflags & FLAG_q)) -- cgit v1.2.3