Hide Forgot
Description of problem: virt-edit -a disk.img /etc/shadow -e 's_^root:.*?:15378:0:99999:7:::_root:$6$SALTsaltUiZikbV3VeeBPsg8./Q5DAfq9aj7CVZMDU6ffBiBLgUEpxv7LMXKbcZ9JSZnYDrZQftdG319XkbLVMvWcF/Vr/:15378:0:99999:7:::_' Bareword found where operator expected at (eval 1) line 1, near "7::" (Missing operator before ::?) Scalar found where operator expected at (eval 1) line 1, near "$6$SALTsaltUiZikbV3VeeBPsg8" (Missing operator before $SALTsaltUiZikbV3VeeBPsg8?) Having no space between pattern and following word is deprecated at (eval 1) line 1, <STDIN> line 1. Bareword found where operator expected at (eval 1) line 1, near "7::" (Missing operator before ::?) syntax error at (eval 1) line 1, near "root:" ...propagated at -e line 1, <STDIN> line 1. However simply changing the s___ expression to s{}{} causes the same command to work. Version-Release number of selected component (if applicable): 1.17.4 How reproducible: 100% Steps to Reproduce: (see above)
After a lot of experimentation, here is a minimal case for the Bareword error: $ virt-edit -a disk.img /etc/shadow -e 's_^root:_root:7:::_' Bareword found where operator expected at (eval 1) line 1, near "7::" (Missing operator before ::?) syntax error at (eval 1) line 1, near "root:" ...propagated at -e line 1, <STDIN> line 1. Removing more of the pattern gives just a syntax error: $ virt-edit -a disk.img /etc/shadow -e 's_^root:_root:_' syntax error at (eval 1) line 1, near "root:" ...propagated at -e line 1, <STDIN> line 1.
The same error happens in plain Perl, eg: $ perl -e 's_^root:_root:7:::_' /etc/passwd Bareword found where operator expected at -e line 1, near "7::" (Missing operator before ::?) syntax error at -e line 1, near "root:" Execution of -e aborted due to compilation errors.
I think what is happening is that the Perl lexer treats s_ as a single terminal, not as s followed by a delimiter underscore. Naturally that completely changes the meaning of the expression. The solution would be to use another delimiter, not _. Note that it works fine using, eg. s{}{}
Other suggestions here: https://rt.perl.org/rt3//Public/Bug/Display.html?id=68804