Hide Forgot
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.
// 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.