[prev in list] [next in list] [prev in thread] [next in thread]
List: dash
Subject: [PATCH 3/6] fc: only parse old=new if -s, per POSIX
From: наб <nabijaczleweli () nabijaczleweli ! xyz>
Date: 2023-02-07 19:33:34
Message-ID: 717f18e61d425cc96d2af5ac3f2c5f1de230f5d3.1675798292.git.nabijaczleweli () nabijaczleweli ! xyz
[Download RAW message or body]
Before (erroneously replaced):
$ a=b set
...
$ fc a=b
8
,
b=b set
After (used as search string):
$ fc a=b
8
,
a=b set
Reported-by: Harald van Dijk <harald@gigawatt.nl>
Reported-in: https://marc.info/?l=dash&m=154707728009743&w=2
---
src/histedit.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/src/histedit.c b/src/histedit.c
index 28956ec..24631ca 100644
--- a/src/histedit.c
+++ b/src/histedit.c
@@ -288,21 +288,18 @@ histcmd(int argc, char **argv)
}
/*
- * If executing, parse [old=new] now
+ * If -s is specified, accept [old=new] first only
*/
- if (lflg == 0 && argc > 0 &&
- ((repl = strchr(argv[0], '=')) != NULL)) {
- pat = argv[0];
- *repl++ = '\0';
- argc--, argv++;
+ if (sflg) {
+ if (argc > 0 && ((repl = strchr(argv[0], '=')) != NULL)) {
+ pat = argv[0];
+ *repl++ = '\0';
+ argc--, argv++;
+ }
+ if (argc >= 2)
+ sh_error("too many args");
}
- /*
- * If -s is specified, accept only one operand
- */
- if (sflg && argc >= 2)
- sh_error("too many args");
-
/*
* determine [first] and [last]
*/
--
2.30.2
["signature.asc" (application/pgp-signature)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic