coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Enhancement Requests + Patch: Unlink to support multiple arguments


From: Pádraig Brady
Subject: Re: Enhancement Requests + Patch: Unlink to support multiple arguments
Date: Tue, 17 Nov 2015 15:51:35 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 17/11/15 12:00, Pádraig Brady wrote:
> On 16/11/15 22:09, Adam Brenner wrote:
>> Howdy All,
>>
>> I have an enhancement requests and patch ready for unlink to support
>> multiple arguments. Currently unlink does not accept more than one
>> argument to remove a link. I have a patch that adds that
>> functionality. For example:
>>
>>     $ unlink link1 link2 link3
>>
>> Is this something the community would like for me to submit?
> 
> I'm not sure about changing unlink to do that.
> unlink has no protection options like -I, -i etc.
> so there is some implicit protection in the fact
> you know it will only ever unlink() one file.
> Consider a user trying to delete extraneous files like:
> 
>   unlink -leading_dash
>   unlink '*.c'
> 
> The implicit protection in the second example
> would prevent any user errors in quoting etc.

Actually the -leading_dash example above doesn't work
as surprisingly unlink verifies that no options are passed.
I'd be inclined to assume that unlink would never accept options,
and thus allow passing files with leading '-' directly with:

diff --git a/src/unlink.c b/src/unlink.c
index 7fba45f..05c3a7c 100644
--- a/src/unlink.c
+++ b/src/unlink.c
@@ -67,8 +67,7 @@ main (int argc, char **argv)

   parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
                       usage, AUTHORS, (char const *) NULL);
-  if (getopt_long (argc, argv, "", NULL, NULL) != -1)
-    usage (EXIT_FAILURE);
+  optind = 1;

   if (argc < optind + 1)
     {

However that would break backwards compat with:

  unlink -- -leading_dash

Ah well.

cheers,
Pádraig.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]