Bug 1293690 - Misbehavior when regexp isn't defined
Misbehavior when regexp isn't defined
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: sed (Show other bugs)
23
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: pstodulk
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-12-22 12:17 EST by Jakub Prokes
Modified: 2016-03-24 18:32 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-03-24 18:32:28 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jakub Prokes 2015-12-22 12:17:57 EST
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 18:32:28 EDT
// 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.