From 5be7ed331daa6ecb39cd8145e78177d051d8655d Mon Sep 17 00:00:00 2001 From: Timothy Sample Date: Sun, 9 Dec 2018 14:08:40 -0500 Subject: [PATCH] sed: Support command lists. --- gash/commands/sed.scm | 2 ++ test/100-sed-command-list.sh | 4 ++++ test/100-sed-command-list.stdout | 2 ++ 3 files changed, 8 insertions(+) create mode 100644 test/100-sed-command-list.sh create mode 100644 test/100-sed-command-list.stdout diff --git a/gash/commands/sed.scm b/gash/commands/sed.scm index ab8b980..6e7a6e1 100644 --- a/gash/commands/sed.scm +++ b/gash/commands/sed.scm @@ -107,6 +107,8 @@ (define (execute-function function str) (match function + (('begin . commands) + (execute-commands commands str)) (('s pattern replacement flags) (substitute str pattern replacement flags)) (_ (error "SED: unsupported function" function)))) diff --git a/test/100-sed-command-list.sh b/test/100-sed-command-list.sh new file mode 100644 index 0000000..b3d918e --- /dev/null +++ b/test/100-sed-command-list.sh @@ -0,0 +1,4 @@ +input='foo +bar' + +echo "$input" | \sed '/foo/ { s/foo/baz/ s/baz/bar/ } s/bar/baz/' diff --git a/test/100-sed-command-list.stdout b/test/100-sed-command-list.stdout new file mode 100644 index 0000000..1f55335 --- /dev/null +++ b/test/100-sed-command-list.stdout @@ -0,0 +1,2 @@ +baz +baz