summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKerin Millar <kfm@plushkava.net>2024-08-02 15:31:54 +0100
committerKerin Millar <kfm@plushkava.net>2024-08-02 17:21:14 +0100
commit2e8bbd04cb55163b3d18ab407ffd8be24bf82c6e (patch)
tree2f3dab2cf0280736681c24a6654312afe34a672b
parentRender hr() faster still for shells other than bash (diff)
downloadgentoo-functions-2e8bbd04cb55163b3d18ab407ffd8be24bf82c6e.tar.gz
gentoo-functions-2e8bbd04cb55163b3d18ab407ffd8be24bf82c6e.tar.bz2
gentoo-functions-2e8bbd04cb55163b3d18ab407ffd8be24bf82c6e.zip
Move is_subset() to experimental
I'm not yet ready to commit to it being among the core functions for the inaugural API level. Signed-off-by: Kerin Millar <kfm@plushkava.net>
-rw-r--r--functions.sh40
-rw-r--r--functions/experimental.sh40
-rwxr-xr-xtest-functions2
3 files changed, 41 insertions, 41 deletions
diff --git a/functions.sh b/functions.sh
index a002e54..69b9bf5 100644
--- a/functions.sh
+++ b/functions.sh
@@ -247,46 +247,6 @@ is_anyof()
}
#
-# Collects the intersection of the parameters up to - but not including - a
-# sentinel value then determines whether the resulting set is a subset of the
-# intersection of the remaining parameters. If the SENTINEL variable is set, it
-# shall be taken as the value of the sentinel. Otherwise, the value of the
-# sentinel shall be defined as <hyphen-dash><hyphen-dash>. If the sentinel value
-# is not encountered or if either set is empty then the return value shall be
-# greater than 1.
-#
-is_subset()
-{
- SENTINEL=${SENTINEL-'--'} awk -f - -- "$@" <<-'EOF'
- BEGIN {
- argc = ARGC
- ARGC = 1
- for (i = 1; i < argc; i++) {
- word = ARGV[i]
- if (word == ENVIRON["SENTINEL"]) {
- break
- } else {
- set1[word]
- }
- }
- if (i == 1 || argc - i < 2) {
- exit 1
- }
- for (i++; i < argc; i++) {
- word = ARGV[i]
- set2[word]
- }
- for (word in set2) {
- delete set1[word]
- }
- for (word in set1) {
- exit 1
- }
- }
- EOF
-}
-
-#
# Considers one or more pathnames and prints the one having the newest
# modification time. If at least one parameter is provided, all parameters shall
# be considered as pathnames to be compared to one another. Otherwise, the
diff --git a/functions/experimental.sh b/functions/experimental.sh
index bbbf0fa..0ca9904 100644
--- a/functions/experimental.sh
+++ b/functions/experimental.sh
@@ -83,6 +83,46 @@ is_interactive()
}
#
+# Collects the intersection of the parameters up to - but not including - a
+# sentinel value then determines whether the resulting set is a subset of the
+# intersection of the remaining parameters. If the SENTINEL variable is set, it
+# shall be taken as the value of the sentinel. Otherwise, the value of the
+# sentinel shall be defined as <hyphen-dash><hyphen-dash>. If the sentinel value
+# is not encountered or if either set is empty then the return value shall be
+# greater than 1.
+#
+is_subset()
+{
+ SENTINEL=${SENTINEL-'--'} awk -f - -- "$@" <<-'EOF'
+ BEGIN {
+ argc = ARGC
+ ARGC = 1
+ for (i = 1; i < argc; i++) {
+ word = ARGV[i]
+ if (word == ENVIRON["SENTINEL"]) {
+ break
+ } else {
+ set1[word]
+ }
+ }
+ if (i == 1 || argc - i < 2) {
+ exit 1
+ }
+ for (i++; i < argc; i++) {
+ word = ARGV[i]
+ set2[word]
+ }
+ for (word in set2) {
+ delete set1[word]
+ }
+ for (word in set1) {
+ exit 1
+ }
+ }
+ EOF
+}
+
+#
# Continuously reads lines from the standard input, prepending each with a
# timestamp before printing to the standard output. Timestamps shall be in the
# format of "%FT%T%z", per strftime(3). Output buffering shall not be employed.
diff --git a/test-functions b/test-functions
index 8070c8d..43b5320 100755
--- a/test-functions
+++ b/test-functions
@@ -909,7 +909,7 @@ else
test_whenceforth || rc=1
test_parallel_run || rc=1
test_is_anyof || rc=1
- test_is_subset || rc=1
+ #test_is_subset || rc=1
test_trueof_all || rc=1
test_trueof_any || rc=1
#test_substr || rc=1