Bug 1293690 - Misbehavior when regexp isn't defined
Summary: Misbehavior when regexp isn't defined
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: sed
Version: 23
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Petr Stodulka
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-12-22 17:17 UTC by Jakub Prokes
Modified: 2016-03-24 22:32 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-03-24 22:32:28 UTC
Type: Bug


Attachments (Terms of Use)

Description Jakub Prokes 2015-12-22 17:17:57 UTC
Description of problem:
When in replace command (s) isn't defined and address is defined by regexp, then sed use address regexp for replacing.

Version-Release number of selected component (if applicable):
sed (GNU sed) 4.2.2
sed-4.2.2-11.fc23.x86_64

How reproducible:
echo -e "foo\nbar" | sed '/o/s//X/'

Actual results:
fXo
bar

Expected results:
sed: -e expression #1, char 0: no previous regular expression

Additional info:
[jprokes@patejl Wallpapers ]$ echo -e "foo\nbar" | sed '/o/s//X/'
fXo
bar
[jprokes@patejl Wallpapers ]$ echo -e "foo\nbar" | sed '1s//X/'
sed: -e expression #1, char 0: no previous regular expression

When I compare these two commands, its behavior is inconsistent and possibly dangerous, in cases when sed is used inside larger bash script.

Comment 1 Paolo Bonzini 2016-03-24 22:32:28 UTC
// is defined to be the last regular expression that was used by the script.  In the case of /o/s//X/, the last regular expression to be tried before executing s//X/ was the address.


Note You need to log in before you can comment on or make changes to this bug.