Skip to content

Commit d6def52

Browse files
authored
Change false, pwd, and true to substitutive built-ins (#124)
2 parents 834ecba + 6db3076 commit d6def52

File tree

4 files changed

+38
-23
lines changed

4 files changed

+38
-23
lines changed

builtin.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ void init_builtin(void)
104104

105105
/* defined in "builtin.c" */
106106
DEFBUILTIN(":", true_builtin, BI_SPECIAL, colon_help, colon_syntax, NULL);
107-
DEFBUILTIN("true", true_builtin, BI_MANDATORY, true_help, true_syntax,
107+
DEFBUILTIN("true", true_builtin, BI_SUBSTITUTIVE, true_help, true_syntax,
108108
NULL);
109-
DEFBUILTIN("false", false_builtin, BI_MANDATORY, false_help, false_syntax,
109+
DEFBUILTIN("false", false_builtin, BI_SUBSTITUTIVE, false_help, false_syntax,
110110
NULL);
111111
#if YASH_ENABLE_HELP
112112
DEFBUILTIN("help", help_builtin, BI_ELECTIVE, help_help, help_syntax,
@@ -119,7 +119,7 @@ void init_builtin(void)
119119
/* defined in "path.c" */
120120
DEFBUILTIN("cd", cd_builtin, BI_MANDATORY, cd_help, cd_syntax,
121121
cd_options);
122-
DEFBUILTIN("pwd", pwd_builtin, BI_MANDATORY, pwd_help, pwd_syntax,
122+
DEFBUILTIN("pwd", pwd_builtin, BI_SUBSTITUTIVE, pwd_help, pwd_syntax,
123123
pwd_options);
124124
DEFBUILTIN("hash", hash_builtin, BI_MANDATORY, hash_help, hash_syntax,
125125
hash_options);

tests/builtins-p.tst

-12
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,6 @@ test_OE -e 0 'intrinsic built-in command can be invoked without $PATH'
329329
command :
330330
__IN__
331331

332-
test_OE 'intrinsic built-in false can be invoked without $PATH'
333-
false
334-
__IN__
335-
336332
# Tested in builtins-y.tst.
337333
#test_OE -e 0 'intrinsic built-in fc can be invoked without $PATH'
338334
#test_OE -e 0 'intrinsic built-in fg can be invoked without $PATH'
@@ -353,19 +349,11 @@ test_OE -e 0 'intrinsic built-in kill can be invoked without $PATH'
353349
kill -0 $$
354350
__IN__
355351

356-
test_E -e 0 'intrinsic built-in pwd can be invoked without $PATH'
357-
pwd
358-
__IN__
359-
360352
test_OE -e 0 'intrinsic built-in read can be invoked without $PATH'
361353
read a
362354
_this_line_is_read_by_the_read_built_in_
363355
__IN__
364356

365-
test_OE -e 0 'intrinsic built-in true can be invoked without $PATH'
366-
true
367-
__IN__
368-
369357
test_E -e 0 'intrinsic built-in type can be invoked without $PATH'
370358
type type
371359
__IN__

tests/command-p.tst

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ __IN__
2424
a
2525
__OUT__
2626

27-
test_OE -e n 'command ignores function (mandatory built-in)'
28-
false () { true; }
29-
command false
27+
test_OE -e 0 'command ignores function (mandatory built-in)'
28+
alias () { false; }
29+
command alias
3030
__IN__
3131

3232
test_E -e 0 'command ignores function (substitutive built-in)'

tests/command-y.tst

+32-5
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,19 @@ unset: a special built-in
8181
__OUT__
8282

8383
test_oE -e 0 'describing mandatory built-ins (-V)'
84-
command -V alias bg cd command false fg getopts hash jobs kill pwd read true \
84+
command -V alias bg cd command fg getopts hash jobs kill read \
8585
type umask unalias wait
8686
__IN__
8787
alias: a mandatory built-in
8888
bg: a mandatory built-in
8989
cd: a mandatory built-in
9090
command: a mandatory built-in
91-
false: a mandatory built-in
9291
fg: a mandatory built-in
9392
getopts: a mandatory built-in
9493
hash: a mandatory built-in
9594
jobs: a mandatory built-in
9695
kill: a mandatory built-in
97-
pwd: a mandatory built-in
9896
read: a mandatory built-in
99-
true: a mandatory built-in
10097
type: a mandatory built-in
10198
umask: a mandatory built-in
10299
unalias: a mandatory built-in
@@ -133,11 +130,41 @@ if ! testee -c 'command -bv echo' >/dev/null; then
133130
skip="true"
134131
fi
135132

136-
test_OE 'describing substitutive built-in (-V)'
133+
test_OE 'describing substitutive built-in echo (-V)'
137134
command -V echo | grep -v "^echo: a substitutive built-in "
138135
__IN__
139136
)
140137

138+
(
139+
if ! testee -c 'command -bv false' >/dev/null; then
140+
skip="true"
141+
fi
142+
143+
test_OE 'describing substitutive built-in false (-V)'
144+
command -V false | grep -v "^false: a substitutive built-in "
145+
__IN__
146+
)
147+
148+
(
149+
if ! testee -c 'command -bv true' >/dev/null; then
150+
skip="true"
151+
fi
152+
153+
test_OE 'describing substitutive built-in true (-V)'
154+
command -V true | grep -v "^true: a substitutive built-in "
155+
__IN__
156+
)
157+
158+
(
159+
if ! testee -c 'command -bv pwd' >/dev/null; then
160+
skip="true"
161+
fi
162+
163+
test_OE 'describing substitutive built-in pwd (-V)'
164+
command -V pwd | grep -v "^pwd: a substitutive built-in "
165+
__IN__
166+
)
167+
141168
test_OE -e 0 'describing external command (-V)'
142169
command -V cat | grep -q '^cat: an external command at'
143170
__IN__

0 commit comments

Comments
 (0)