summaryrefslogtreecommitdiffstats
path: root/main/augeas/0001-Shellvars-allow-partial-quoting-mixing-multiple-styl.patch
blob: b3d7012ae134a26fc2861cd0c51ad60a9d29e102 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
From 937653cbb1f9681a575e0fa5e8f2d0e59fd9ab5c Mon Sep 17 00:00:00 2001
From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Date: Thu, 4 Dec 2014 14:31:26 +0200
Subject: [PATCH 1/5] Shellvars: allow partial quoting, mixing multiple styles

---
 lenses/shellvars.aug            | 8 ++++----
 lenses/tests/test_shellvars.aug | 4 ++++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/lenses/shellvars.aug b/lenses/shellvars.aug
index 073f69b..60091a9 100644
--- a/lenses/shellvars.aug
+++ b/lenses/shellvars.aug
@@ -31,7 +31,7 @@ module Shellvars =
   let xchgs   = Build.xchgs
   let semicol = del /;?/ ""
 
-  let char  = /[^`;() '"\t\n]|\\\\"/
+  let char  = /[^`;() '"\t\n\\]|\\\\./
   let dquot =
        let char = /[^"\\]|\\\\./ | Rx.cl
     in "\"" . char* . "\""                    (* " Emacs, relax *)
@@ -42,7 +42,7 @@ module Shellvars =
   let dollar_assign = /\$\([^\(\)#\n]*\)/
   let dollar_arithm = /\$\(\([^\)#\n]*\)\)/
 
-  let anyquot = (dquot|squot)+ | bquot | dbquot | dollar_assign | dollar_arithm
+  let anyquot = (char|dquot|squot|dollar_assign|dollar_arithm)+ | bquot | dbquot
 
   let to_semicol_re = /[^#; \t\n][^#;\n]+[^#; \t\n]|[^#; \t\n]+/
   let sto_to_semicol = store to_semicol_re
@@ -57,7 +57,7 @@ module Shellvars =
   (* arrays here because of typechecking headaches. Instead, they are    *)
   (* treated as a simple value                                           *)
   let array =
-    let array_value = store (char+ | anyquot) in
+    let array_value = store anyquot in
     del /\([ \t]*/ "(" . counter "values" .
       [ seq "values" . array_value ] .
       [ del /[ \t\n]+/ " " . seq "values" . array_value ] *
@@ -67,7 +67,7 @@ module Shellvars =
   (* but fairly close.                                                *)
   let simple_value =
     let empty_array = /\([ \t]*\)/ in
-      store (char* | anyquot | empty_array)
+      store (anyquot | empty_array)?
 
   let export = [ key "export" . Util.del_ws_spc ]
   let kv = Util.indent . export? . key key_re
diff --git a/lenses/tests/test_shellvars.aug b/lenses/tests/test_shellvars.aug
index 42fc2bd..e4fd79f 100644
--- a/lenses/tests/test_shellvars.aug
+++ b/lenses/tests/test_shellvars.aug
@@ -399,6 +399,10 @@ esac\n" =
   test Shellvars.lns get "FOO=``bar``\n" =
   { "FOO" = "``bar``" }
 
+  (* Partial quoting is allowed *)
+  test Shellvars.lns get "FOO=\"$bar\"/'baz'/$(quux)$((1 + 2))\n" =
+  { "FOO" = "\"$bar\"/'baz'/$(quux)$((1 + 2))" }
+
   (* unset can be used on wildcard variables *)
   test Shellvars.lns get "unset ${!LC_*}\n" =
   { "@unset"
-- 
1.8.3.1