diff options
author | Andrew Cady <d@jerkface.net> | 2024-01-24 18:51:03 -0500 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2024-01-24 18:51:03 -0500 |
commit | ccd9ffb85800be3614be7a4d6ed36013982dc2ed (patch) | |
tree | 300a6998cdaf26ed3a74cb5b9d8943a37ac2402b | |
parent | 4d22f4d73a9f8042dc6fc0b79ca9ed321c70d5be (diff) |
add to docs and add test case
-rw-r--r-- | wordpress/export-json.bash | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/wordpress/export-json.bash b/wordpress/export-json.bash index 3438821..fa1f41e 100644 --- a/wordpress/export-json.bash +++ b/wordpress/export-json.bash | |||
@@ -9,7 +9,7 @@ | |||
9 | # Example: | 9 | # Example: |
10 | # | 10 | # |
11 | # $ ( | 11 | # $ ( |
12 | # source export-json.bash | 12 | # source export-json.bash && |
13 | # export_JSON SSH_TTY \ | 13 | # export_JSON SSH_TTY \ |
14 | # SSH_CONNECTION \ | 14 | # SSH_CONNECTION \ |
15 | # SSH_CLIENT \ | 15 | # SSH_CLIENT \ |
@@ -35,7 +35,8 @@ | |||
35 | # Variable names are given to the function as its | 35 | # Variable names are given to the function as its |
36 | # argument list: | 36 | # argument list: |
37 | # | 37 | # |
38 | # $ (source export-json.bash; export_JSON PATH) | 38 | # $ source export-json.bash && |
39 | # export_JSON PATH | ||
39 | # | 40 | # |
40 | # The output is a single JSON object containing | 41 | # The output is a single JSON object containing |
41 | # key-value mappings between JSON strings: | 42 | # key-value mappings between JSON strings: |
@@ -44,6 +45,15 @@ | |||
44 | # "PATH": "/usr/local/sbin:[...]" | 45 | # "PATH": "/usr/local/sbin:[...]" |
45 | # } | 46 | # } |
46 | # | 47 | # |
48 | # It is possible to use a different name for the | ||
49 | # variable in the JSON object key field than in | ||
50 | # the shell environment, like this: | ||
51 | # | ||
52 | # $ export_JSON DBUS_SESSION_BUS_ADDRESS=p | ||
53 | # { | ||
54 | # "p": "unix:path=/run/user/1000/bus" | ||
55 | # } | ||
56 | # | ||
47 | # It uses the external tool "jq" to parse string | 57 | # It uses the external tool "jq" to parse string |
48 | # values placed in jq's argument list by bash and | 58 | # values placed in jq's argument list by bash and |
49 | # then encode them as JSON string values. This | 59 | # then encode them as JSON string values. This |
@@ -137,4 +147,5 @@ runtest() | |||
137 | try export_JSON | 147 | try export_JSON |
138 | try export_JSON '' | 148 | try export_JSON '' |
139 | try export_JSON '' SSH_TTY | 149 | try export_JSON '' SSH_TTY |
150 | try export_JSON SSH_TTY '' | ||
140 | } | 151 | } |