Bug 788486 - virt-edit -e: Bareword found where operator expected
Summary: virt-edit -e: Bareword found where operator expected
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libguestfs
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Richard W.M. Jones
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-02-08 09:49 UTC by Richard W.M. Jones
Modified: 2012-02-08 10:18 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-02-08 10:18:26 UTC


Attachments (Terms of Use)

Description Richard W.M. Jones 2012-02-08 09:49:09 UTC
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 10:06:19 UTC
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 10:09:34 UTC
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 10:16:22 UTC
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 10:18:26 UTC
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.