holzschu / holzschu/a-shell

Possible bug using 'sed' in dash

Open
#479 4 comments 0 reactions 0 assignees View on GitHub
fix committed
Dominant language
Perl
Stars
3.9k
Forks
213
Avg merge
1m
Merged PRs (30d)
1

Description

Hello. I don't know if this is a bug or not, but I believe that it may be. When I run the following command in the regular a-Shell, I get the desired result shown by the output of the command below:

[Documents]$ echo "test.mp4" | sed -E 's/\\.//g'
testmp4
[Documents]$

However, if I run the same command in the dash shell (having run dash in the a-Shell), I get an empty line as output as shown by the execution of the command in dash and its corresponding output below:

[\W]$ echo "test.mp4" | sed -E 's/\\.//g'

[\W]$

It seems that the '\\.' in the 'sed' command is interpreted as '.' and all of the characters are replaced by '' thus erasing all of them.

If, on the other hand, I use two backslashes before the '.' in the 'sed' command, I get the same output as the output of the first command above run in the regular a-Shell, as shown below:

[\W]$ echo "test.mp4" | sed -E 's/\\\\\.//g'
testmp4
[\W]$

I believe that two slashes should not be necessary, but only one because this would be the correct syntax for the regular expression for the 'sed' command. Would this be a bug in your estimation?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.