summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2024-01-24 14:04:30 -0500
committerAndrew Cady <d@jerkface.net>2024-01-24 14:04:30 -0500
commitc5ee7bc21587a0a0da32217e23170b3a9f8dee75 (patch)
tree15e41d80b6d3ffb8bc85034f3f3073abfe673c40
parent10181102aa7427e829a417cb985a511e300cf7ad (diff)
documentation
-rw-r--r--wordpress/export-json.bash45
1 files changed, 25 insertions, 20 deletions
diff --git a/wordpress/export-json.bash b/wordpress/export-json.bash
index d021173..0b5d35a 100644
--- a/wordpress/export-json.bash
+++ b/wordpress/export-json.bash
@@ -1,22 +1,27 @@
1#!/bin/bash 1#!/bin/bash
2# 2#
3# export_JSON <variables>
4#
5# Synopsis: 3# Synopsis:
6# 4#
7# $ ( 5# #!/bin/bash
8# source export-json.bash 6# . export-json.bash
9# export_JSON SSH_TTY \ 7# export_JSON <variables>
10# SSH_CONNECTION \ 8#
11# SSH_CLIENT \ 9# Example:
12# SSH_AUTH_SOCK 10#
13# ) 11# $ (
14# { 12# source export-json.bash
15# "SSH_TTY": "/dev/pts/0", 13# export_JSON SSH_TTY \
16# "SSH_CONNECTION": "192.0.2.140 41564 198.51.100.25 22", 14# SSH_CONNECTION \
17# "SSH_CLIENT": "192.0.2.140 41564 22", 15# SSH_CLIENT \
18# "SSH_AUTH_SOCK": "/tmp/ssh-XXXXcePKJl/agent.36326" 16# SSH_AUTH_SOCK
19# } 17# )
18#
19# {
20# "SSH_TTY": "/dev/pts/0",
21# "SSH_CONNECTION": "192.0.2.140 41564 198.51.100.25 22",
22# "SSH_CLIENT": "192.0.2.140 41564 22",
23# "SSH_AUTH_SOCK": "/tmp/ssh-XXXXcePKJl/agent.36326"
24# }
20# 25#
21# This bash function exports shell variables as 26# This bash function exports shell variables as
22# JSON ("javascript object notation") strings. 27# JSON ("javascript object notation") strings.
@@ -25,19 +30,19 @@
25# 30#
26# JSON is a format that represents data as 31# JSON is a format that represents data as
27# Javascript source code so modern programmers 32# Javascript source code so modern programmers
28# can read it unlike bash source code. 33# can read it unlike bash source code.
29# 34#
30# Variable names are given to the function as its 35# Variable names are given to the function as its
31# argument list: 36# argument list:
32# 37#
33# $ (source export-json.bash; export_JSON PATH) 38# $ (source export-json.bash; export_JSON PATH)
34# 39#
35# The output is a single JSON object containing 40# The output is a single JSON object containing
36# key-value mappings between JSON strings: 41# key-value mappings between JSON strings:
37# 42#
38# { 43# {
39# "PATH": "/usr/local/sbin:[...]" 44# "PATH": "/usr/local/sbin:[...]"
40# } 45# }
41# 46#
42# It uses the external tool "jq" to parse string 47# It uses the external tool "jq" to parse string
43# values placed in jq's argument list by bash and 48# values placed in jq's argument list by bash and