Bug 788486 - virt-edit -e: Bareword found where operator expected
virt-edit -e: Bareword found where operator expected
Status: CLOSED NOTABUG
Product: Virtualization Tools
Classification: Community
Component: libguestfs (Show other bugs)
unspecified
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Richard W.M. Jones
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-02-08 04:49 EST by Richard W.M. Jones
Modified: 2012-02-08 05:18 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-02-08 05:18:26 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Richard W.M. Jones 2012-02-08 04:49:09 EST
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)
Comment 1 Richard W.M. Jones 2012-02-08 05:06:19 EST
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.
Comment 2 Richard W.M. Jones 2012-02-08 05:09:34 EST
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.
Comment 3 Richard W.M. Jones 2012-02-08 05:16:22 EST
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{}{}
Comment 4 Richard W.M. Jones 2012-02-08 05:18:26 EST
Other suggestions here:
https://rt.perl.org/rt3//Public/Bug/Display.html?id=68804

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