Skip to content

Commit 2e69b1f

Browse files
committed
fix shfmt issues
1 parent f7f45fe commit 2e69b1f

File tree

3 files changed

+46
-40
lines changed

3 files changed

+46
-40
lines changed

examples/config-ini/README.md

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ fi
119119
config_load config.ini
120120
config_show
121121
122-
# Or to iterate through keys manually
123-
for key in "${!config[@]}"; do
124-
echo "$key = ${config[$key]}"
125-
done
122+
## Or to iterate through keys manually
123+
# for key in $(config_keys); do
124+
# echo "$key = ${config[$key]}"
125+
# done
126126
```
127127

128128
## `src/set_command.sh`
@@ -135,8 +135,8 @@ key="${args[key]}"
135135
value="${args[value]}"
136136
137137
config["$key"]="$value"
138-
config_show
139138
config_save saved.ini
139+
cat saved.ini
140140
141141
```
142142

@@ -170,15 +170,19 @@ Options:
170170
171171
```
172172

173-
### `$ ./configly set hello world`
173+
### `$ ./configly set hello WORLD`
174174

175175
```shell
176176
bashly = works
177-
hello = world
178-
options.name = value for options.name
179-
options.path = value for options.path
180-
user.email = value for user.email
181-
user.name = value for user.name
177+
hello = WORLD
178+
179+
[options]
180+
name = value for options.name
181+
path = value for options.path
182+
183+
[user]
184+
email = value for user.email
185+
name = value for user.name
182186
183187
184188
```
@@ -188,10 +192,14 @@ user.name = value for user.name
188192
```shell
189193
bashly = works
190194
hello = world
191-
options.name = value for options.name
192-
options.path = value for options.path
193-
user.email = value for user.email
194-
user.name = Megatron
195+
196+
[options]
197+
name = value for options.name
198+
path = value for options.path
199+
200+
[user]
201+
email = value for user.email
202+
name = Megatron
195203
196204
197205
```
@@ -225,9 +233,13 @@ No such key: invalid_key
225233
```shell
226234
bashly = works
227235
hello = world
228-
options.name = value for options.name
229-
options.path = value for options.path
230-
user.name = value for user.name
236+
237+
[options]
238+
name = value for options.name
239+
path = value for options.path
240+
241+
[user]
242+
name = value for user.name
231243
232244
233245
```
@@ -241,12 +253,6 @@ options.name = value for options.name
241253
options.path = value for options.path
242254
user.email = value for user.email
243255
user.name = value for user.name
244-
bashly = works
245-
hello = world
246-
options.path = value for options.path
247-
user.name = value for user.name
248-
options.name = value for options.name
249-
user.email = value for user.email
250256
251257
252258
```

examples/config-ini/src/lib/config.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ config_load() {
2727
value="${BASH_REMATCH[2]}"
2828
config["${section}${key}"]="$value"
2929
fi
30-
done < "$config_file"
30+
done <"$config_file"
3131
}
3232

3333
## Save the array back to a file
@@ -42,23 +42,23 @@ config_save() {
4242
[[ $key == *.* ]] && continue
4343
has_free_keys=true
4444
value="${config[$key]}"
45-
echo "$key = $value" >> "$filename"
45+
echo "$key = $value" >>"$filename"
4646
done
4747

48-
[[ "${has_free_keys}" == "true" ]] && echo >> "$filename"
48+
[[ "${has_free_keys}" == "true" ]] && echo >>"$filename"
4949

5050
for key in $(config_keys); do
5151
[[ $key == *.* ]] || continue
5252
value="${config[$key]}"
53-
IFS="." read -r section_name key_name <<< "$key"
53+
IFS="." read -r section_name key_name <<<"$key"
5454

5555
if [[ "$current_section" != "$section_name" ]]; then
56-
[[ $current_section ]] && echo >> "$filename"
57-
echo "[$section_name]" >> "$filename"
56+
[[ $current_section ]] && echo >>"$filename"
57+
echo "[$section_name]" >>"$filename"
5858
current_section="$section_name"
5959
fi
6060

61-
echo "$key_name = $value" >> "$filename"
61+
echo "$key_name = $value" >>"$filename"
6262
done
6363
}
6464

@@ -72,5 +72,5 @@ config_show() {
7272
## Return a newline delimited, sorted list of keys
7373
config_keys() {
7474
local keys=("${!config[@]}")
75-
for a in "${keys[@]}"; do echo "$a"; done |sort
75+
for a in "${keys[@]}"; do echo "$a"; done | sort
7676
}

lib/bashly/libraries/config/config.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ config_load() {
2727
value="${BASH_REMATCH[2]}"
2828
config["${section}${key}"]="$value"
2929
fi
30-
done < "$config_file"
30+
done <"$config_file"
3131
}
3232

3333
## Save the array back to a file
@@ -42,23 +42,23 @@ config_save() {
4242
[[ $key == *.* ]] && continue
4343
has_free_keys=true
4444
value="${config[$key]}"
45-
echo "$key = $value" >> "$filename"
45+
echo "$key = $value" >>"$filename"
4646
done
4747

48-
[[ "${has_free_keys}" == "true" ]] && echo >> "$filename"
48+
[[ "${has_free_keys}" == "true" ]] && echo >>"$filename"
4949

5050
for key in $(config_keys); do
5151
[[ $key == *.* ]] || continue
5252
value="${config[$key]}"
53-
IFS="." read -r section_name key_name <<< "$key"
53+
IFS="." read -r section_name key_name <<<"$key"
5454

5555
if [[ "$current_section" != "$section_name" ]]; then
56-
[[ $current_section ]] && echo >> "$filename"
57-
echo "[$section_name]" >> "$filename"
56+
[[ $current_section ]] && echo >>"$filename"
57+
echo "[$section_name]" >>"$filename"
5858
current_section="$section_name"
5959
fi
6060

61-
echo "$key_name = $value" >> "$filename"
61+
echo "$key_name = $value" >>"$filename"
6262
done
6363
}
6464

@@ -72,5 +72,5 @@ config_show() {
7272
## Return a newline delimited, sorted list of keys
7373
config_keys() {
7474
local keys=("${!config[@]}")
75-
for a in "${keys[@]}"; do echo "$a"; done |sort
75+
for a in "${keys[@]}"; do echo "$a"; done | sort
7676
}

0 commit comments

Comments
 (0)