Skip to content
This repository was archived by the owner on May 20, 2024. It is now read-only.

Commit 4555998

Browse files
CodingMarkusCodingMarkus
CodingMarkus
authored and
CodingMarkus
committed
Fix ifs naming and tests
1 parent 1349bb5 commit 4555998

File tree

2 files changed

+27
-30
lines changed

2 files changed

+27
-30
lines changed

lib/psst/basic/ifs.inc.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ esac
99
INCLUDE_SEEN_PSST="$INCLUDE_SEEN_PSST _ifs.inc.sh_"
1010

1111

12-
# shellcheck source=stack.inc.sh
13-
. "$INCLUDE_PSST/basic/stack.inc.sh"
14-
1512
# shellcheck source=assert.inc.sh
1613
. "$INCLUDE_PSST/basic/assert.inc.sh"
1714

15+
# shellcheck source=stack.inc.sh
16+
. "$INCLUDE_PSST/basic/stack.inc.sh"
17+
1818

1919
##
2020
# FUNCTION
21-
# set_ifs_psst [<newValue>]
21+
# ifs_set_psst [<newValue>]
2222
#
2323
# SUMMARY
2424
# Save the current IFS value to a stack and replace it with a new value. New
@@ -33,17 +33,17 @@ INCLUDE_SEEN_PSST="$INCLUDE_SEEN_PSST _ifs.inc.sh_"
3333
# 1: Current $IFS value could not be saved.
3434
#
3535
# SAMPLE
36-
# set_ifs_psst "$FS_CHAR_PSST"
36+
# ifs_set_psst "$FS_CHAR_PSST"
3737
#
38-
set_ifs_psst()
38+
ifs_set_psst()
3939
{
4040
#newIFSValue=$1
4141

4242
# We cannot use a subshell for this function as we need to register the
4343
# variables in the main shell. Thus we need to be careful to not conflict
4444
# when defining local variables.
4545

46-
_func_psst="set_ifs_psst"
46+
_func_psst="ifs_set_psst"
4747
assert_argc_psst "$_func_psst" 1 $#
4848
unset _func_psst
4949

@@ -57,22 +57,22 @@ set_ifs_psst()
5757

5858
##
5959
# FUNCTION
60-
# restore_ifs_psst
60+
# ifs_restore_psst
6161
#
6262
# SUMMARY
6363
# Restore the last saved IFS value or set IFS to default if no value has been
6464
# saved at all or all saved values have already been restored.
6565
##
6666
# SAMPLE
67-
# restore_ifs_psst
67+
# ifs_restore_psst
6868
#
69-
restore_ifs_psst()
69+
ifs_restore_psst()
7070
{
7171
# We cannot use a subshell for this function as we need to register the
7272
# variables in the main shell. Thus we need to be careful to not conflict
7373
# when defining local variables.
7474

75-
_func_psst="set_ifs_psst"
75+
_func_psst="ifs_restore_psst"
7676
assert_argc_psst "$_func_psst" 0 $#
7777
unset _func_psst
7878

test/basic/bin/test_ifs.sh

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,17 @@ fi
1616

1717
# set_ifs must accept exactly one argument
1818
set +e
19-
( abspath_psst 2>/dev/null )
19+
( ifs_set_psst 2>/dev/null )
2020
[ $? = 127 ] || test_fail_psst $LINENO
2121

22-
( abspath_psst 1 2 2>/dev/null )
22+
( ifs_set_psst 1 2 2>/dev/null )
2323
[ $? = 127 ] || test_fail_psst $LINENO
2424
set -e
2525

2626

27-
# restore_ifs_psst must accept exactly no argument
27+
# ifs_restore must accept exactly no argument
2828
set +e
29-
( abspath_psst 2>/dev/null )
30-
[ $? = 127 ] || test_fail_psst $LINENO
31-
32-
( abspath_psst 1 2 2>/dev/null )
29+
( ifs_restore_psst 1 2>/dev/null )
3330
[ $? = 127 ] || test_fail_psst $LINENO
3431
set -e
3532

@@ -38,46 +35,46 @@ set -e
3835
# Test push, pop
3936
oldIFS="$IFS"
4037

41-
set_ifs_psst "a" || test_fail_psst $LINENO
38+
ifs_set_psst "a" || test_fail_psst $LINENO
4239
test "$IFS" == "a" || test_fail_psst $LINENO
4340

44-
restore_ifs_psst
41+
ifs_restore_psst
4542
test "$IFS" = "$oldIFS" || test_fail_psst $LINENO
4643

4744

4845
# Test push, push, pop, pop
4946
oldIFS="$IFS"
5047

51-
set_ifs_psst "a" || test_fail_psst $LINENO
48+
ifs_set_psst "a" || test_fail_psst $LINENO
5249
test "$IFS" == "a" || test_fail_psst $LINENO
5350

54-
set_ifs_psst "b" || test_fail_psst $LINENO
51+
ifs_set_psst "b" || test_fail_psst $LINENO
5552
test "$IFS" == "b" || test_fail_psst $LINENO
5653

57-
restore_ifs_psst
54+
ifs_restore_psst
5855
test "$IFS" == "a" || test_fail_psst $LINENO
5956

60-
restore_ifs_psst
57+
ifs_restore_psst
6158
test "$IFS" = "$oldIFS" || test_fail_psst $LINENO
6259

6360

6461
# Test push, push, pop, push, pop, pop
6562
oldIFS="$IFS"
6663

67-
set_ifs_psst "a" || test_fail_psst $LINENO
64+
ifs_set_psst "a" || test_fail_psst $LINENO
6865
test "$IFS" == "a" || test_fail_psst $LINENO
6966

70-
set_ifs_psst "b" || test_fail_psst $LINENO
67+
ifs_set_psst "b" || test_fail_psst $LINENO
7168
test "$IFS" == "b" || test_fail_psst $LINENO
7269

73-
restore_ifs_psst
70+
ifs_restore_psst
7471
test "$IFS" == "a" || test_fail_psst $LINENO
7572

76-
set_ifs_psst "c" || test_fail_psst $LINENO
73+
ifs_set_psst "c" || test_fail_psst $LINENO
7774
test "$IFS" == "c" || test_fail_psst $LINENO
7875

79-
restore_ifs_psst
76+
ifs_restore_psst
8077
test "$IFS" == "a" || test_fail_psst $LINENO
8178

82-
restore_ifs_psst
79+
ifs_restore_psst
8380
test "$IFS" = "$oldIFS" || test_fail_psst $LINENO

0 commit comments

Comments
 (0)