File: oscap-run-sce-script

package info (click to toggle)
openscap 1.4.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 125,040 kB
  • sloc: xml: 527,109; ansic: 91,390; sh: 19,789; python: 2,515; perl: 444; makefile: 49
file content (24 lines) | stat: -rwxr-xr-x 571 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env bash
#
# Authors:
#      Dominique Blaze <contact@d0m.tech>
#
# use by oscap for evaluate a SCE file when +x rights are missing

if [ ! -z $1 ] && [ -f $1 ] 
then
	# file exists. first check if shebang is here 
	
	firstline=$(head -n1 $1)
	if [ ${firstline:0:2} = "#!" ]
	then  # it's a shebang
		cmd=${firstline:2}  # remove the begin (#!)
		cmd=${cmd##*( )}  # trim whitespaces
		eval $cmd $1 > /dev/stdout
	else  # no shebang, trying bash by default ...
		/usr/bin/env bash $1 > /dev/stdout
	fi
	
else
	echo "Script file not found: $1" > /dev/stderr
fi