Skip to content
This repository was archived by the owner on Jun 16, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions features/fts.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include <fts.h>

int main() {
}
11 changes: 11 additions & 0 deletions features/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,17 @@ posix_spawn_feature_result = cc.run(posix_spawn_feature_file,
args: feature_test_args)
feature_data.set10('_lib_posix_spawn', posix_spawn_feature_result.returncode() == 0)

# Meson adds -D_FILE_OFFSET_BITS=64 flag by default, but it does not work with fts functions in older versions
# of glibc. This feture test undefines it on such systems.
# https://github.com/mesonbuild/meson/issues/3519
fts_feature_file = files('fts.c')
fts_feature_result = cc.compiles(fts_feature_file,
name: 'Check if -D_FILE_OFFSET_BITS=64 works with fts functions',
args: feature_test_args + ['-D_FILE_OFFSET_BITS=64'])
if not fts_feature_result
add_global_arguments('-U_FILE_OFFSET_BITS', language: 'c')
endif

newgrp = find_program('newgrp', required: false)
feature_data.set10('_cmd_newgrp', newgrp.found())

Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/tests/basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ float sec=SECONDS
file=$TEST_DIR/foobar
log_info "TODO: Skipping call to builtin cat"

#builtin cat
builtin cat
for ((n=0; n < 1000; n++))
do
> $file
Expand Down
46 changes: 22 additions & 24 deletions src/cmd/ksh93/tests/builtins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
########################################################################

# test shell builtin commands
# builtin getconf
builtin getconf
: ${foo=bar} || log_error ": failed"
[[ $foo == bar ]] || log_error ": side effects failed"
set -- - foobar
Expand Down Expand Up @@ -690,7 +690,7 @@ $SHELL 2> /dev/null -c 'cd ""' && log_error 'cd "" not producing an error'
[[ $($SHELL 2> /dev/null -c 'cd "";print hi') != hi ]] && log_error 'cd "" should not terminate script'

bincat=$(whence -p cat)
# builtin cat
builtin cat
out=$TEST_DIR/seq.out
seq 11 >$out
cmp -s <(print -- "$($bincat<( $bincat $out ) )") <(print -- "$(cat <( cat $out ) )") || log_error "builtin cat differs from $bincat"
Expand Down Expand Up @@ -797,27 +797,26 @@ IFS=',' read -S a b c <<<'foo,"""title"" data",bar'
[[ $b == '"title" data' ]] || log_error '"" inside "" not handled correctly with read -S'

PATH=/bin:/usr/bin
log_info 'TODO: Enable these tests when the custom builtins of external commands are available.'
#basename=$(whence -p basename)
#cmp=$(whence -p cmp)
#.sh.op_astbin=/opt/ast/bin
#PATH=/opt/ast/bin:$PATH
#PATH=/opt/ast/bin:/bin:/usr/bin
#[[ ${SH_OPTIONS} == *astbin=/opt/ast/bin* ]] || log_error "SH_OPTIONS=${SH_OPTIONS} but should contain astbin=/opt/ast/bin"
#[[ $(whence basename) == /opt/ast/bin/basename ]] || log_error "basename bound to $(whence basename) but should be bound to /opt/ast/bin/basename"
#[[ $(whence cmp) == /opt/ast/bin/cmp ]] || log_error "cmp bound to $(whence cmp) but should be bound to /opt/ast/bin/cmp"
#.sh.op_astbin=/bin
#SH_OPTIONS=astbin=/bin
#[[ ${SH_OPTIONS} == *astbin=/bin* ]] || log_error "SH_OPTIONS=${SH_OPTIONS} but should contain astbin=/bin"
#[[ $(whence basename) == "$basename" ]] || log_error "basename bound to $(whence basename) but should be bound to $basename"
#[[ $(whence cmp) == "$cmp" ]] || log_error "cmp bound to $(whence cmp) but should be bound to $cmp"
#.sh.op_astbin=/opt/ast/bin
#[[ $(whence basename) == /opt/ast/bin/basename ]] || log_error "basename bound to $(whence basename) but should be rebound to /opt/ast/bin/basename"
#[[ $(whence cmp) == /opt/ast/bin/cmp ]] || log_error "cmp bound to $(whence cmp) but should be rebound to /opt/ast/bin/cmp"
#PATH=/bin:/usr/bin:/opt/ast/bin
#[[ $(whence basename) == "$basename" ]] || log_error "basename bound to $(whence basename) but should be bound to $basename when PATH=$PATH"
#[[ $(whence cmp) == "$cmp" ]] || log_error "cmp bound to $(whence cmp) but should be bound to $cmp when PATH=$PATH"
#
basename=$(whence -p basename)
cmp=$(whence -p cmp)
.sh.op_astbin=/opt/ast/bin
PATH=/opt/ast/bin:$PATH
PATH=/opt/ast/bin:/bin:/usr/bin
[[ ${SH_OPTIONS} == *astbin=/opt/ast/bin* ]] || log_error "SH_OPTIONS=${SH_OPTIONS} but should contain astbin=/opt/ast/bin"
[[ $(whence basename) == /opt/ast/bin/basename ]] || log_error "basename bound to $(whence basename) but should be bound to /opt/ast/bin/basename"
[[ $(whence cmp) == /opt/ast/bin/cmp ]] || log_error "cmp bound to $(whence cmp) but should be bound to /opt/ast/bin/cmp"
.sh.op_astbin=/bin
SH_OPTIONS=astbin=/bin
[[ ${SH_OPTIONS} == *astbin=/bin* ]] || log_error "SH_OPTIONS=${SH_OPTIONS} but should contain astbin=/bin"
[[ $(whence basename) == /bin/basename ]] || log_error "basename bound to $(whence basename) but should be bound to /bin/basename"
[[ $(whence cmp) == /bin/cmp ]] || log_error "cmp bound to $(whence cmp) but should be bound to /bin/cmp"
.sh.op_astbin=/opt/ast/bin
[[ $(whence basename) == /opt/ast/bin/basename ]] || log_error "basename bound to $(whence basename) but should be rebound to /opt/ast/bin/basename"
[[ $(whence cmp) == /opt/ast/bin/cmp ]] || log_error "cmp bound to $(whence cmp) but should be rebound to /opt/ast/bin/cmp"
PATH=/bin:/usr/bin:/opt/ast/bin
[[ $(whence basename) == "$basename" ]] || log_error "basename bound to $(whence basename) but should be bound to $basename when PATH=$PATH"
[[ $(whence cmp) == "$cmp" ]] || log_error "cmp bound to $(whence cmp) but should be bound to $cmp when PATH=$PATH"

unset y
expect='outside f, 1, 2, 3, outside f'
actual=$(
Expand Down Expand Up @@ -977,7 +976,6 @@ then
fi
chmod +x $TEST_DIR/a/b # so the test temp dir can be removed when the test completes


# -s flag writes to history file
if print -s 'print hello world' 2> /dev/null
then
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/tests/coprocess.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function ping # id
}

bincat=$(whence -p cat)
#builtin cat
builtin cat

for cat in cat $bincat
do
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/tests/exit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function abspath
# this for it to succeed.
cd $TEST_DIR || { err_exit "cd $TEST_DIR failed"; exit 1; }

# builtin getconf
builtin getconf
ABSHELL=$(abspath)
print exit 0 >.profile
${ABSHELL} <<!
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/ksh93/tests/heredoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ then
fi

cat > "$f" <<- '!!!!'
# builtin cat
builtin cat
: << EOF
$PWD
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Expand Down Expand Up @@ -526,7 +526,7 @@ $SHELL 2> /dev/null -c 'true <<- ++EOF++ || true "$(true)"
) > $f > /dev/null
[[ $(<$f) == $'hello\nworld' ]] || log_error 'nested here-document fails'

# builtin cat
builtin cat
exp='foo bar baz bork blah blarg'
got=$(cat <<<"foo bar baz" 3<&0 <<<"$(</dev/fd/3) bork blah blarg")
[[ $got == "$exp" ]] || '3<%0 not working when 0 is <<< here-doc'
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/tests/io.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ $SHELL -c '
done > in
> out
exec 1<> out
# builtin cat
builtin cat
print -r -- "$(<in)"
cmp -s in out' 2> /dev/null
[[ $? == 0 ]] || log_error 'builtin cat truncates files'
Expand Down
35 changes: 17 additions & 18 deletions src/cmd/ksh93/tests/locale.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,24 +113,23 @@ set -- $($SHELL -c "
")
got=$*
[[ $got == $exp ]] || log_error "command wc LC_ALL default failed -- expected '$exp', got '$got'"
log_info 'TODO: Enable when custom builtins of external commands is working.'
#set -- $($SHELL -c "
# if builtin wc 2>/dev/null || builtin -f cmd wc 2>/dev/null
# then
# unset LC_CTYPE
# export LANG=$locale
# export LC_ALL=C
# wc -m < $TEST_DIR/two_euro_chars.txt
# unset LC_ALL
# wc -m < $TEST_DIR/two_euro_chars.txt
# export LC_ALL=C
# wc -m < $TEST_DIR/two_euro_chars.txt
# fi

#")
#got=$*
#[[ $got == $exp ]] || log_error "builtin wc LC_ALL default failed -- expected '$exp', got '$got'"
#
set -- $($SHELL -c "
if builtin wc 2>/dev/null || builtin -f cmd wc 2>/dev/null
then
unset LC_CTYPE
export LANG=$locale
export LC_ALL=C
wc -m < $TEST_DIR/two_euro_chars.txt
unset LC_ALL
wc -m < $TEST_DIR/two_euro_chars.txt
export LC_ALL=C
wc -m < $TEST_DIR/two_euro_chars.txt
fi

")
got=$*
[[ $got == $exp ]] || log_error "builtin wc LC_ALL default failed -- expected '$exp', got '$got'"

# multibyte char straddling buffer boundary

# See https://github.com/att/ast/issues/177
Expand Down
5 changes: 2 additions & 3 deletions src/cmd/ksh93/tests/path.sh
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,8 @@ typeset foo=$(PATH=/xyz:/abc :)
y=$(whence rm)
[[ $x != "$y" ]] && log_error 'PATH not restored after command substitution'
whence getconf > /dev/null && log_error 'getconf should not be found'
log_info "TODO: If and when builtins are supported uncomment the next two lines and remove the third."
#builtin /bin/getconf
#PATH=/bin
builtin /bin/getconf
PATH=/bin
PATH=$path
PATH="$(getconf PATH)"
x=$(whence ls)
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/tests/subshell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# #
########################################################################

# builtin getconf
builtin getconf
bincat=$(PATH=$(getconf PATH) whence -p cat)

z=()
Expand Down
160 changes: 0 additions & 160 deletions src/lib/libast/include/fts.h

This file was deleted.

4 changes: 2 additions & 2 deletions src/lib/libast/misc/fts.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ fts_flags(void)
if (streq(s, "logical"))
return FTS_LOGICAL;
if (streq(s, "physical"))
return FTS_PHYSICAL|FTS_SEEDOTDIR;
return FTS_META|FTS_PHYSICAL|FTS_SEEDOTDIR;
return FTS_PHYSICAL|FTS_SEEDOT;
return FTS_COMFOLLOW|FTS_PHYSICAL|FTS_SEEDOT;
}
Loading