Bug 1056527

Summary: Augeas lens bug: shellvars and case statements with same-line ;; tokens
Product: [Fedora] Fedora Reporter: Filip Krska <fkrska>
Component: augeasAssignee: Dominic Cleal <dcleal>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 20CC: apevec, asanders, dcleal, lkong, lutter, mbooth, mkolaja
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: augeas-1.3.0-1.fc21 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1033799 Environment:
Last Closed: 2015-01-05 09:19:23 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1033799    
Bug Blocks:    
Attachments:
Description Flags
support for oneliners in case lutter: review+

Comment 1 Filip Krska 2014-01-22 16:08:55 UTC
It seems, that the problem is the 'entry*' field which is supposed to be in between "choice)" and ";;" in case_entry defined in
/usr/share/augeas/lenses/dist/shellvars.aug

All types of entries are terminated with "comment_or_eol" which is comment "\n" or ";" unlike shell's "list" which it is probably aimed to interpret. List according to `man bash` is _optionally_ terminated by one of ;, &, or <newline>.

In order to support broader subset of valid "case" styles kind of "_noeol" variants of entries should be introduced (there's no ; or "\n" required before ";;"), I see no one-liner fix here.

What I see as another problem is incomplete documentation (http://augeas.net/docs/references/lenses/files/shellvars-aug.html states TBD). It's obvious from shellvars.aug, that the Shellvars lens does support relatively small subset of shell syntax (e.g. only "ulimit" | "shift" | "exit" builtins and no arbitrary commands, so usage of e.g. "echo" breaks the load) so documentation should exist and specify what is supported and set expectations properly.

Comment 2 Filip Krska 2014-01-29 12:46:45 UTC
Created attachment 857046 [details]
support for oneliners in case

Proposing patch adding support for (reasonable subset of) oneliners in case entries.

However, I treat this rather as a quick non-invasive dirty fix of this particular hot use case than a final fix.

IMHO all entries should be defined according to shell's "list" philosophy i.e. not ending with comment_or_eol and occurrences of entry* should be replaced with something like `(entry . comment_or_eol)*` where ; or eol is mandatory and `(entry . comment_or_eol)* . entry?` where optional.

Comment 3 Dominic Cleal 2014-02-12 12:37:30 UTC
Fixed in a1b9831d14f22f81cf7dc840160c08cc14234ee9 upstream.

Comment 4 Dominic Cleal 2015-01-05 09:19:23 UTC
Fixed in Fedora 21 and rawhide, via Augeas 1.3.0.