[sed] did not replace correctly
With the following test.file:
[&_*]:foobar
"[&_*]:foobar"
With actual sed on macOS:
$ sed 's/\[\([^\&]*\)\&/\[\1\&/g' test.file
[&_*]:foobar
"[&_*]:foobar"
With shx sed:
npx shx sed 's/\[\([^\&]*\)\&/\[\1\&/g' test.txt
[&_*]:foobar
"[&_*]:foobar"
Node version: v20.12.2
After reading shelljs doc on sed, the replacement must be a JS replacement string, i.e. shx sed 's/\[([^\&]*)\&/[$1&/g'.
So in term of being a wrapper around shelljs, this is not a bug in shx.
However, being a shell replacement for sed, it is a surprised, as I would expect the same syntax as sed.
Also, in sed, open and close parentheses need to be escaped I believe, but not with shx.
Thanks for the report. Getting shx sed to be 100% compatible has been a challenge. I'd be willing to accept a contribution to the shx project if you're interested in working on this.
How does the current behavior compare to sed -e ... (extended regex syntax)?