diff options
author | Rob Landley <rob@landley.net> | 2012-11-22 21:18:09 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2012-11-22 21:18:09 -0600 |
commit | fe91e68e8d1e6a2974b57a9855032ad94d137e8e (patch) | |
tree | c6a347d54dae31c9572008133d6610df8c8dc475 /toys/other | |
parent | bd2e2279d2b8f491ff9a56f6bd9000b0215778f8 (diff) | |
download | toybox-fe91e68e8d1e6a2974b57a9855032ad94d137e8e.tar.gz |
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().
Diffstat (limited to 'toys/other')
-rw-r--r-- | toys/other/readlink.c | 18 |
1 files changed, 6 insertions, 12 deletions
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 <rob@landley.net> -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)) |