separate has_shebang_line tests

This commit is contained in:
Thomas Levine 2016-03-31 19:26:11 +00:00
parent edda2a0e90
commit 72ea60bb8d
8 changed files with 16 additions and 21 deletions

1
tests/Internals/bash Executable file
View File

@ -0,0 +1 @@
run '!#/bin/bash'

1
tests/Internals/empty Executable file
View File

@ -0,0 +1 @@
! run ''

5
tests/Internals/empty-line Executable file
View File

@ -0,0 +1,5 @@
! run '
'

1
tests/Internals/env Executable file
View File

@ -0,0 +1 @@
run '!#/usr/bin/env true'

View File

@ -1,20 +0,0 @@
TESTING_URCHIN_INTERNALS=true . ../../urchin
echo '!#/bin/sh' > $tmp
! has_shebang_line $tmp
echo '!#/bin/bash' > $tmp
has_shebang_line $tmp
echo '!#/usr/bin/env true' > $tmp
has_shebang_line $tmp
echo > $tmp
! has_shebang_line $tmp
echo '
' > $tmp
! has_shebang_line $tmp

View File

@ -1 +1,7 @@
export tmp=$(mktemp) export tmp=$(mktemp)
run() {
TESTING_URCHIN_INTERNALS=true . ../../urchin
echo "$1" > $tmp
has_shebang_line $tmp
}

1
tests/Internals/sh Executable file
View File

@ -0,0 +1 @@
! run '!#/bin/sh'

2
urchin
View File

@ -414,7 +414,7 @@ report_outcome() {
} }
has_shebang_line() { has_shebang_line() {
head -n 1 "${1}" | grep -q -v '^#!/bin/sh' head -n 1 "${1}" | grep -v '^#!/bin/sh$' | grep -q '^#!'
} }
USAGE="usage: $0 [options]... [test file or directory]..." USAGE="usage: $0 [options]... [test file or directory]..."