From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 71e0a0ca for ; Thu, 21 Mar 2019 04:14:20 +0000 (UTC) Received: (qmail 29724 invoked by alias); 21 Mar 2019 04:14:09 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 44153 Received: (qmail 24335 invoked by uid 1010); 21 Mar 2019 04:14:08 -0000 X-Qmail-Scanner-Diagnostics: from mail-ot1-f43.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.1/25393. spamassassin: 3.4.2. Clear:RC:0(209.85.210.43):SA:0(-1.8/5.0):. Processed in 2.927804 secs); 21 Mar 2019 04:14:08 -0000 X-Envelope-From: phy1729@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.210.43 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mail-followup-to:mime-version :content-disposition:user-agent; bh=HMk9v2s9rLKhs0gqDBWgM/JhI+7CWxJg7VlKEgassOs=; b=M9GuiC6pjuiUHVLATCAQfskcMQOUOJe3ebheH5TwNsQJwBnfC51tdfRwUB7LKViU9c QJnrfNvBbLLtie6EinC2/oftucRTf9ZvNXy6V19TD2x3GUgkcksRx22xKL3G23t621s7 RmlfAWhyENGQEbSws273bgT9DQDS38/lsKxW2W7g09ziMRZj1rduuk6VTh+CxJMvYO0G O5Su/+unP0UMeoMN/+nbTL/ZMuO8n3W2SNvu/AQZqdRBV3o1PhveYfVrNTacPnkgeY1f 3LGmjsaG3w62dN8X4ztT/CfldANdtooNVQ0sF6FN8POW0gOxxF7tQ+0vQa9B3Mia08/z uNkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :mime-version:content-disposition:user-agent; bh=HMk9v2s9rLKhs0gqDBWgM/JhI+7CWxJg7VlKEgassOs=; b=WDP+93HOZvgRPzvjXx3m3WX6Rme8YtL20pgKDZGHYsY37XCU2GslCeuoGiEzS9MoIR 2Au8unsLg3jjvnO1ZqYqe06frQq5a23+1xZdZpyagcJ/YiWAUBGe1LR/uqaZfRt13kDN R/Gr/1jhrWuxlGyeDwtAB5QCQD5EDQpPc0tY4Z0ut4tI6q77Hm3m/8Cosjm75Pk5BpzD 4E71mOGrNw6jtghpHNnbwBXVgB3ITuOrKJzNcbdlSogVBELibqyM1aUvSuVwE8266P9n 49O06BTBI84i0VMVtP/W8a6BUFcLOO0Pc/oJeeUNyxP2X039qLCVueOFZDl8GUZ6cRLV vq/A== X-Gm-Message-State: APjAAAXYIPCLlAg4HKc4v0zzPDQklY+47CNH6mN3q1bHRFFToEZyHaiP gKbl7kALXvVykH+WPuPVC334reOa X-Google-Smtp-Source: APXvYqzw8yRzeOolB1GLQAhluxxDLpYkrldJeYk7SMXyDVozB85SQK1ZgBsT2E4zy9719Xso3l78jw== X-Received: by 2002:a9d:7246:: with SMTP id a6mr1077657otk.246.1553141612078; Wed, 20 Mar 2019 21:13:32 -0700 (PDT) Date: Wed, 20 Mar 2019 23:13:29 -0500 From: Matthew Martin To: zsh-workers@zsh.org Subject: [PATCH] rm: Accept -R as equivalent to -r Message-ID: <20190321041326.GA58005@CptOrmolo.darkstar> Mail-Followup-To: zsh-workers@zsh.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.11.4 (2019-03-13) While updating the completers for builtins, I ran across that rm doesn't support -R while it does support -r. POSIX defines -R and -r as equivalent. I think it's easier to just support -R in the builtin rm than fix the completer. - Matthew Martin --- Doc/Zsh/mod_files.yo | 14 +++++++------- Src/Modules/files.c | 7 ++++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Doc/Zsh/mod_files.yo b/Doc/Zsh/mod_files.yo index 3cf7b61e3..9f9634c86 100644 --- a/Doc/Zsh/mod_files.yo +++ b/Doc/Zsh/mod_files.yo @@ -144,15 +144,15 @@ fall back on copying and removing files; if this behaviour is desired, use tt(cp) and tt(rm) manually. This may change in a future version. ) findex(rm) -item(tt(rm) [ tt(-dfirs) ] var(filename) ...)( +item(tt(rm) [ tt(-dfiRrs) ] var(filename) ...)( Removes files and directories specified. -Normally, tt(rm) will not remove directories (except with the tt(-r) -option). The tt(-d) option causes tt(rm) to try removing directories +Normally, tt(rm) will not remove directories (except with the tt(-R) or tt(-r) +options). The tt(-d) option causes tt(rm) to try removing directories with tt(unlink) (see manref(unlink)(2)), the same method used for files. Typically only the super-user can actually succeed in unlinking directories in this way. -tt(-d) takes precedence over tt(-r). +tt(-d) takes precedence over tt(-R) and tt(-r). By default, the user will be queried before removing any file that the user cannot write to, but writable files will be silently @@ -162,9 +162,9 @@ any files. The tt(-f) option causes files to be silently deleted, without querying, and suppresses all error indications. tt(-f) takes precedence. -The tt(-r) option causes tt(rm) to recursively descend into directories, -deleting all files in the directory before removing the directory with -the tt(rmdir) system call (see manref(rmdir)(2)). +The tt(-R) and tt(-r) options cause tt(rm) to recursively descend into +directories, deleting all files in the directory before removing the directory +with the tt(rmdir) system call (see manref(rmdir)(2)). The tt(-s) option is a zsh extension to tt(rm) functionality. It enables paranoid behaviour, intended to avoid common security problems involving diff --git a/Src/Modules/files.c b/Src/Modules/files.c index 85764d55e..6d20e38a8 100644 --- a/Src/Modules/files.c +++ b/Src/Modules/files.c @@ -613,7 +613,8 @@ bin_rm(char *nam, char **args, Options ops, UNUSED(int func)) rmm.opt_interact = OPT_ISSET(ops,'i') && !OPT_ISSET(ops,'f'); rmm.opt_unlinkdir = OPT_ISSET(ops,'d'); err = recursivecmd(nam, OPT_ISSET(ops,'f'), - OPT_ISSET(ops,'r') && !OPT_ISSET(ops,'d'), + !OPT_ISSET(ops,'d') && (OPT_ISSET(ops,'R') || + OPT_ISSET(ops,'r')), OPT_ISSET(ops,'s'), args, recurse_donothing, rm_dirpost, rm_leaf, &rmm); return OPT_ISSET(ops,'f') ? 0 : err; @@ -798,7 +799,7 @@ static struct builtin bintab[] = { BUILTIN("ln", 0, bin_ln, 1, -1, BIN_LN, LN_OPTS, NULL), BUILTIN("mkdir", 0, bin_mkdir, 1, -1, 0, "pm:", NULL), BUILTIN("mv", 0, bin_ln, 2, -1, BIN_MV, "fi", NULL), - BUILTIN("rm", 0, bin_rm, 1, -1, 0, "dfirs", NULL), + BUILTIN("rm", 0, bin_rm, 1, -1, 0, "dfiRrs", NULL), BUILTIN("rmdir", 0, bin_rmdir, 1, -1, 0, NULL, NULL), BUILTIN("sync", 0, bin_sync, 0, 0, 0, NULL, NULL), /* The "safe" zsh-only names */ @@ -808,7 +809,7 @@ static struct builtin bintab[] = { BUILTIN("zf_ln", 0, bin_ln, 1, -1, BIN_LN, LN_OPTS, NULL), BUILTIN("zf_mkdir", 0, bin_mkdir, 1, -1, 0, "pm:", NULL), BUILTIN("zf_mv", 0, bin_ln, 2, -1, BIN_MV, "fi", NULL), - BUILTIN("zf_rm", 0, bin_rm, 1, -1, 0, "dfirs", NULL), + BUILTIN("zf_rm", 0, bin_rm, 1, -1, 0, "dfiRrs", NULL), BUILTIN("zf_rmdir", 0, bin_rmdir, 1, -1, 0, NULL, NULL), BUILTIN("zf_sync", 0, bin_sync, 0, 0, 0, NULL, NULL), -- 2.21.0