summaryrefslogtreecommitdiff
path: root/mk/wrapper/wrapper-subr.sh
blob: ac7d194679f47c81c188be9c0248f72e9d278be2 (plain)
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
# $NetBSD: wrapper-subr.sh,v 1.7 2006/11/30 12:59:56 rillig Exp $
#
# This file contains shell functions that are useful to the wrapper
# scripts.
#

# usage: transform_setname "current-file"
transform_setname() {
	wrapsubr_name="$1"
}

# usage: transform_to "newarg"
transform_to() {
	arg="$1"
	$debug_log $wrapperlog "    ($wrapsubr_name) to: $1"
	addtocache=yes
}

# usage: transform_to_and_split "newarg"
transform_to_and_split() {
	arg="$1"
	$debug_log $wrapperlog "    ($wrapsubr_name) to: $1 [split]"
	addtocache=yes
	split_arg=yes
}

# usage: transform_discard
transform_discard() {
	$debug_log $wrapperlog "    ($wrapsubr_name) discarded: $arg"
	arg=""
	addtocache=yes
	split_arg=yes
}

# usage: transform_discard_with_warning [warning]
transform_discard_with_warning() {
	_warning=${1-"discarding option $arg"}
	msg_log "$wrapperlog" "WARNING: [$wrapsubr_name] $_warning"
	transform_discard
	addtocache=no
}

# usage: transform_pass
transform_pass() {
	$debug_log $wrapperlog "    ($wrapsubr_name) to: $arg [unchanged]"
	addtocache=yes
}

# usage: transform_pass_with_warning [warning]
transform_pass_with_warning() {
	_warning=${1-"passing option $arg"}
	msg_log "$wrapperlog" "WARNING: [$wrapsubr_name] $_warning"
	$debug_log $wrapperlog "    ($wrapsubr_name) to: $arg [unchanged]"
	addtocache=no
}