File: example.filefd

package info (click to toggle)
shellia 5.7.6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 728 kB
  • sloc: sh: 7,087; makefile: 34
file content (60 lines) | stat: -rwxr-xr-x 1,485 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
# vim: set filetype=sh :
#        file: example.filefd
#   copyright: Bernd Schumacher <bernd.schumacher@hpe.com> (2007-2021)
#     license: GNU General Public License, version 3
# description: test calling shellia script in separate file on local host
#    see also: test.filefd

set -e
set -u

. ./ia

eval "$ia_init"

filelog=""
file=""
while [ $# -gt 0 ]; do
  if [ "$1" = "--file" ]; then
    file="yes"
    shift
  elif [ "$1" = "--log" ]; then
    ia_check_logfile "$2"
    shift 2
  elif [ "$1" = "--filelog" ]; then
    file="yes"
    filelog="$2"
    shift 2
  else
    cat <<END >&2
Usage: example_filefd [--file] [--log <logfile>] [--filelog <file-logfile>]
  <logfile>       logs to logfile <logfile>
  <file-logfile>  implies --file and logs file to <file-logfile>
  --file          run separate file,
                  if only <logfile> is set, and not <file-logfile>
                  also file logs go to <logfile>
END
    exit 1
  fi
done

if [ "$file" ]; then

  testdir="$(realpath .)"

  ia_add "ia_log \"example_filefd-1: will run separate file\""
  ia_add "ia_logerr \"example_filefd-2: ia_logfile=<$<ia_logfile>> ia_log_fd=<$<ia_log_fd>>\""

  if [ "$filelog" ]; then
    ia_nocheck
    ia_add "ia_file $0 <-i> --log $filelog"
  else
    ia_nocheck
    ia_add "ia_file $0 <-i>"
  fi
else
  ia_add "ia_log \"example_filefd-3: running own script\""
  ia_add "ia_logerr \"example_filefd-4: ia_logfile=<$<ia_logfile>> ia_log_fd=<$<ia_log_fd>>\""
fi
ia -c