File tree Expand file tree Collapse file tree 8 files changed +62
-58
lines changed Expand file tree Collapse file tree 8 files changed +62
-58
lines changed Original file line number Diff line number Diff line change
1
+ # DONE
2
+ # Copyright 2006-2022 Alan K. Stebbens <
[email protected] >
3
+ #
4
+ # A change log for the bash-lib
5
+
6
+ 2022/07/17
7
+ * Makefile:
8
+ - make invocation path explicitly relative
9
+ * hash-utils.sh:
10
+ - sort the keys for printing on hash_print
11
+
1
12
2015/05/31
2
- * sh-utils.sh:
13
+ * sh-utils.sh:
3
14
- refactored into talk-utils, arg-utils, run-utils
4
15
* Makefile:
5
16
- added the newly refactored modules
21
32
* test-text-utils.sh:
22
33
- refactored all the tests to support new STDIN feature
23
34
* sh-utils.sh:
24
- - added args_or_stdin function to pass along ars, or
35
+ - added args_or_stdin function to pass along ars, or
25
36
read from STDIN
26
37
27
38
2014/06/11
Original file line number Diff line number Diff line change 1
1
# hash-utils.sh
2
- # Copyright 2014-2015 Alan K. Stebbens <[email protected] >
2
+ # Copyright 2014-2022 Alan K. Stebbens <[email protected] >
3
3
#
4
4
# bash script utilities for managing hashes (associative arrays)
5
5
@@ -313,23 +313,16 @@ print_hash() { "$@" ; }
313
313
# hash_print_items VAR
314
314
hash_print_items () {
315
315
help_args_func hash_help $# || return
316
- local var=" $1 " k
316
+ local var=" $1 " key val
317
317
local -a keys
318
318
hash_get_keys $var
319
- for k in " ${keys[@]} " ; do
320
- hash_print_item $var " $k "
321
- echo ' '
319
+ __list_sort keys
320
+ for key in " ${keys[@]} " ; do
321
+ val=` hash_get $var " $key " `
322
+ printf " %s['%s']='%s'\n" $var " $key " " $val "
322
323
done
323
324
}
324
325
325
- # hash_print_item VAR KEY
326
-
327
- hash_print_item () {
328
- local var=" $1 " key=" $2 "
329
- local val=` hash_get $var " $key " `
330
- printf " %s['%s']='%s'" $var " $key " " $val "
331
- }
332
-
333
326
# _set_args "OPT1 OPT2 ..." "$@"
334
327
#
335
328
# Scan the arguments looking for OPTn=VAL, and set each OPTn to the
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
- # Copyright 2006-2014 , Alan K. Stebbens <[email protected] >
3
- #
2
+ # Copyright 2006-2022 , Alan K. Stebbens <[email protected] >
3
+ #
4
4
# Test module for hash-utils.sh
5
5
#
6
6
@@ -136,7 +136,7 @@ test_10_print_hash() {
136
136
apple banana cherry dog elephant fox giraffe hawk indigo manzana milk november
137
137
october december january february march april may june july august
138
138
)
139
- hash_init hash10
139
+ hash_init hash10
140
140
for (( i= 0 ; i< ${# words[@]} ; i++ )) ; do
141
141
hash_set hash10 ${words[i]} $i
142
142
done
Original file line number Diff line number Diff line change 1
- hash10['april ']='17 ' hash10['apple ']='0 ' hash10['november ']='11 '
2
- hash10['cherry ']='2 ' hash10['march ']='16 ' hash10['august ']='21 '
3
- hash10['october ']='12 ' hash10['indigo ']='8' hash10['may']='18'
4
- hash10['giraffe ']='6 ' hash10['june ']='19 ' hash10['banana ']='1 '
5
- hash10['february ']='15 ' hash10['milk ']='10 ' hash10['manzana ']='9 '
6
- hash10['july ']='20 ' hash10['january']='14' hash10['fox ']='5 '
7
- hash10['dog']='3' hash10['hawk ']='7'
8
- hash10['elephant']='4' hash10['december ']='13'
1
+ hash10['apple ']='0 ' hash10['february ']='15 ' hash10['manzana ']='9 '
2
+ hash10['april ']='17 ' hash10['fox ']='5 ' hash10['march ']='16 '
3
+ hash10['august ']='21 ' hash10['giraffe ']='6' hash10['may']='18'
4
+ hash10['banana ']='1 ' hash10['hawk ']='7 ' hash10['milk ']='10 '
5
+ hash10['cherry ']='2 ' hash10['indigo ']='8 ' hash10['november ']='11 '
6
+ hash10['december ']='13 ' hash10['january']='14' hash10['october ']='12 '
7
+ hash10['dog']='3' hash10['july ']='20'
8
+ hash10['elephant']='4' hash10['june ']='19'
Original file line number Diff line number Diff line change 1
- hash10['april ']='17 ' hash10['apple ']='0 ' hash10['november ']='11 '
2
- hash10['cherry ']='2 ' hash10['march ']='16 ' hash10['august ']='21 '
3
- hash10['october ']='12 ' hash10['indigo ']='8' hash10['may']='18'
4
- hash10['giraffe ']='6 ' hash10['june ']='19 ' hash10['banana ']='1 '
5
- hash10['february ']='15 ' hash10['milk ']='10 ' hash10['manzana ']='9 '
6
- hash10['july ']='20 ' hash10['january']='14' hash10['fox ']='5 '
7
- hash10['dog']='3' hash10['hawk ']='7 '
8
- hash10['elephant']='4' hash10['december ']='13 '
1
+ hash10['apple ']='0 ' hash10['february ']='15 ' hash10['manzana ']='9 '
2
+ hash10['april ']='17 ' hash10['fox ']='5 ' hash10['march ']='16 '
3
+ hash10['august ']='21 ' hash10['giraffe ']='6' hash10['may']='18'
4
+ hash10['banana ']='1 ' hash10['hawk ']='7 ' hash10['milk ']='10 '
5
+ hash10['cherry ']='2 ' hash10['indigo ']='8 ' hash10['november ']='11 '
6
+ hash10['december ']='13 ' hash10['january']='14' hash10['october ']='12 '
7
+ hash10['dog']='3' hash10['july ']='20 '
8
+ hash10['elephant']='4' hash10['june ']='19 '
Original file line number Diff line number Diff line change 1
- hash10['april ']='17 ' hash10['dog']='3' hash10['milk ']='10' hash10['may']='18'
2
- hash10['cherry ']='2 ' hash10['elephant']='4' hash10['january']='14' hash10['banana ']='1 '
3
- hash10['october ']='12 ' hash10['apple ']='0 ' hash10['hawk ']='7 ' hash10['manzana ']='9 '
4
- hash10['giraffe ']='6 ' hash10['march ']='16 ' hash10['december ']='13 ' hash10['fox ']='5 '
5
- hash10['february ']='15 ' hash10['indigo ']='8 ' hash10['november ']='11 '
6
- hash10['july ']='20 ' hash10['june ']='19 ' hash10['august ']='21 '
1
+ hash10['apple ']='0 ' hash10['dog']='3' hash10['indigo ']='8' hash10['may']='18'
2
+ hash10['april ']='17 ' hash10['elephant']='4' hash10['january']='14' hash10['milk ']='10 '
3
+ hash10['august ']='21 ' hash10['february ']='15 ' hash10['july ']='20 ' hash10['november ']='11 '
4
+ hash10['banana ']='1 ' hash10['fox ']='5 ' hash10['june ']='19 ' hash10['october ']='12 '
5
+ hash10['cherry ']='2 ' hash10['giraffe ']='6 ' hash10['manzana ']='9 '
6
+ hash10['december ']='13 ' hash10['hawk ']='7 ' hash10['march ']='16 '
Original file line number Diff line number Diff line change 1
- hash10['april ']='17 ' hash10['apple ']='0 ' hash10['november ']='11 '
2
- hash10['cherry ']='2 ' hash10['march ']='16 ' hash10['august ']='21 '
3
- hash10['october ']='12 ' hash10['indigo ']='8' hash10['may']='18'
4
- hash10['giraffe ']='6 ' hash10['june ']='19 ' hash10['banana ']='1 '
5
- hash10['february ']='15 ' hash10['milk ']='10 ' hash10['manzana ']='9 '
6
- hash10['july ']='20 ' hash10['january']='14' hash10['fox ']='5 '
7
- hash10['dog']='3' hash10['hawk ']='7 '
8
- hash10['elephant']='4' hash10['december ']='13 '
1
+ hash10['apple ']='0 ' hash10['february ']='15 ' hash10['manzana ']='9 '
2
+ hash10['april ']='17 ' hash10['fox ']='5 ' hash10['march ']='16 '
3
+ hash10['august ']='21 ' hash10['giraffe ']='6' hash10['may']='18'
4
+ hash10['banana ']='1 ' hash10['hawk ']='7 ' hash10['milk ']='10 '
5
+ hash10['cherry ']='2 ' hash10['indigo ']='8 ' hash10['november ']='11 '
6
+ hash10['december ']='13 ' hash10['january']='14' hash10['october ']='12 '
7
+ hash10['dog']='3' hash10['july ']='20 '
8
+ hash10['elephant']='4' hash10['june ']='19 '
Original file line number Diff line number Diff line change 1
- hash10['april ']='17 ' hash10['june ']='19 '
2
- hash10['cherry ']='2 ' hash10['milk ']='10 '
3
- hash10['october ']='12' hash10['january']='14'
4
- hash10['giraffe ']='6 ' hash10['hawk ']='7 '
5
- hash10['february ']='15 ' hash10['december ']='13 '
6
- hash10['july ']='20 ' hash10['november ']='11 '
7
- hash10['dog']='3' hash10['august ']='21 '
1
+ hash10['apple ']='0 ' hash10['hawk ']='7 '
2
+ hash10['april ']='17 ' hash10['indigo ']='8 '
3
+ hash10['august ']='21' hash10['january']='14'
4
+ hash10['banana ']='1 ' hash10['july ']='20 '
5
+ hash10['cherry ']='2 ' hash10['june ']='19 '
6
+ hash10['december ']='13 ' hash10['manzana ']='9 '
7
+ hash10['dog']='3' hash10['march ']='16 '
8
8
hash10['elephant']='4' hash10['may']='18'
9
- hash10['apple ']='0 ' hash10['banana ']='1 '
10
- hash10['march ']='16 ' hash10['manzana ']='9 '
11
- hash10['indigo ']='8 ' hash10['fox ']='5 '
9
+ hash10['february ']='15 ' hash10['milk ']='10 '
10
+ hash10['fox ']='5 ' hash10['november ']='11 '
11
+ hash10['giraffe ']='6 ' hash10['october ']='12 '
You can’t perform that action at this time.
0 commit comments