From b5ebe959cca84101795ec29022af5fcbcb94ed78 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 29 Jul 2017 19:10:03 -0400 Subject: exec: Don't allow anything between {} and + POSIX explicitly forbids this extension: > Only a that immediately follows an argument containing > only the two characters "{}" shall punctuate the end of the primary > expression. Other uses of the shall not be treated as > special. --- tests.sh | 58 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 27 deletions(-) (limited to 'tests.sh') diff --git a/tests.sh b/tests.sh index 53d7189..dcecb01 100755 --- a/tests.sh +++ b/tests.sh @@ -187,6 +187,7 @@ posix_tests=( test_size_bytes test_exec test_exec_plus + test_exec_plus_semicolon test_flag_comma test_perm_222 test_perm_222_minus @@ -224,15 +225,15 @@ bsd_tests=( test_size_big test_exec_substring test_execdir_pwd + test_execdir_slash + test_execdir_slash_pwd + test_execdir_slashes test_double_dash test_flag_double_dash test_ok_stdin test_okdir_stdin test_delete test_rm - test_execdir_slash - test_execdir_slash_pwd - test_execdir_slashes test_regex test_iregex test_regex_parens @@ -301,7 +302,11 @@ gnu_tests=( test_exec_substring test_execdir test_execdir_substring + test_execdir_plus_semicolon test_execdir_pwd + test_execdir_slash + test_execdir_slash_pwd + test_execdir_slashes test_weird_names test_flag_weird_names test_follow_comma @@ -316,9 +321,6 @@ gnu_tests=( test_perm_symbolic_slash test_perm_leading_plus_symbolic_slash test_delete - test_execdir_slash - test_execdir_slash_pwd - test_execdir_slashes test_regex test_iregex test_regex_parens @@ -363,9 +365,7 @@ bfs_tests=( test_perm_symbolic_missing_action test_perm_leading_plus_symbolic test_perm_octal_plus - test_exec_plus_substring test_execdir_plus - test_execdir_plus_substring test_hidden test_nohidden test_path_flag_expr @@ -746,12 +746,16 @@ function test_exec_plus() { bfs_diff basic -exec "$TESTS/sort-args.sh" '{}' + } -function test_exec_substring() { - bfs_diff basic -exec echo '-{}-' ';' +function test_exec_plus_semicolon() { + # POSIX says: + # Only a that immediately follows an argument containing only the two characters "{}" + # shall punctuate the end of the primary expression. Other uses of the shall not be + # treated as special. + bfs_diff basic -exec "$TESTS/sort-args.sh" foo '{}' bar + baz \; } -function test_exec_plus_substring() { - bfs_diff basic -exec "$TESTS/sort-args.sh" a '-{}-' z + +function test_exec_substring() { + bfs_diff basic -exec echo '-{}-' ';' } function test_execdir() { @@ -766,8 +770,8 @@ function test_execdir_substring() { bfs_diff basic -execdir echo '-{}-' ';' } -function test_execdir_plus_substring() { - bfs_diff basic -execdir "$TESTS/sort-args.sh" a '-{}-' z + +function test_execdir_plus_semicolon() { + bfs_diff basic -execdir "$TESTS/sort-args.sh" foo '{}' bar + baz \; } function test_execdir_pwd() { @@ -776,6 +780,19 @@ function test_execdir_pwd() { bfs_diff basic -execdir bash -c "pwd | cut -b$OFFSET-" ';' } +function test_execdir_slash() { + # Don't prepend ./ for absolute paths in -execdir + bfs_diff / -maxdepth 0 -execdir echo '{}' ';' +} + +function test_execdir_slash_pwd() { + bfs_diff / -maxdepth 0 -execdir pwd ';' +} + +function test_execdir_slashes() { + bfs_diff /// -maxdepth 0 -execdir echo '{}' ';' +} + function test_weird_names() { cd weirdnames bfs_diff '-' '(-' '!-' ',' ')' './(' './!' \( \! -print , -print \) @@ -938,19 +955,6 @@ function test_rm() { bfs_diff scratch } -function test_execdir_slash() { - # Don't prepend ./ for absolute paths in -execdir - bfs_diff / -maxdepth 0 -execdir echo '{}' ';' -} - -function test_execdir_slash_pwd() { - bfs_diff / -maxdepth 0 -execdir pwd ';' -} - -function test_execdir_slashes() { - bfs_diff /// -maxdepth 0 -execdir echo '{}' ';' -} - function test_regex() { bfs_diff basic -regex 'basic/./.' } -- cgit v1.2.3