fix for local variable problem in EXIT trap; add sed-like behavior for null patterns in pattern substitution

This commit is contained in:
Chet Ramey
2022-07-19 11:42:23 -04:00
parent 87a6e89edc
commit 52ae6c3f5d
12 changed files with 125 additions and 45 deletions
+8
View File
@@ -780,6 +780,14 @@ let\&ee
let\&ee
let&ee
let&ee
twoone
&twoone
onetwo
one&two
two
&two
otwone
&twone
argv[1] = </>
argv[1] = </>
+17
View File
@@ -101,3 +101,20 @@ echo ${var//$pat/"\&"}
echo ${var//$pat/"$r3"}
echo ${var//$pat/"&"}
echo ${var//$pat/$r3}
# these cases provide the same functionality as sed when given a BRE like
# `^' or `$', or when passed a null input line
one=one
null=
echo ${one/#/&two}
echo ${one/#/\&two}
echo ${one/%/&two}
echo ${one/%/\&two}
echo ${null/#/&two}
echo ${null/#/\&two}
echo ${one/#?/&two}
echo ${one/#?/\&two}