summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2010-07-09 10:41:24 +0200
committerMarc Kleine-Budde <mkl@pengutronix.de>2010-07-15 13:28:07 +0200
commita7e72cb90c294188935e31163509a64969fe010b (patch)
tree98a6f49745841619a6b6d13caf1cdfbe3fc23186 /scripts
parent9e69780c57b27ea6641f5693c990aa6e4f8444c1 (diff)
downloadptxdist-a7e72cb90c294188935e31163509a64969fe010b.tar.gz
ptxdist-a7e72cb90c294188935e31163509a64969fe010b.tar.xz
[libptxdist] ptxd_replace_magic: don't replace unset MAGICs
This patch changes the semantics of the function. Originally all @MAGIC@ are replaced with their environemnt value. Even if MAGIC is unset in the env, resulting in @MAGIC@ to be removed from the output. With this patch ptxd_replace_magic will only replace @MAGIC@ if MAGIC is set in the environment. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/libptxdist.sh14
1 files changed, 10 insertions, 4 deletions
diff --git a/scripts/libptxdist.sh b/scripts/libptxdist.sh
index d94cc5eef..632bd37b8 100644
--- a/scripts/libptxdist.sh
+++ b/scripts/libptxdist.sh
@@ -369,7 +369,8 @@ ptxd_make_log() {
#
-# replaces @MAGIC@ with MAGIC from environment
+# replaces @MAGIC@ with MAGIC from environment (if available)
+# it will stay @MAGIC@ if MAGIC is unset in the environment
#
# $1 input file
# stdout: output
@@ -377,9 +378,14 @@ ptxd_make_log() {
ptxd_replace_magic() {
gawk '
$0 ~ /@[A-Z0-9_]+@/ {
- while (match($0, "@[A-Z0-9_]+@")) {
- var = substr($0, RSTART+1, RLENGTH-2);
- gsub("@" var "@", ENVIRON[var]);
+ line = $0
+
+ while (match(line, "@[A-Z0-9_]+@")) {
+ var = substr(line, RSTART + 1, RLENGTH - 2);
+ line = substr(line, RSTART + RLENGTH);
+
+ if (var in ENVIRON)
+ gsub("@" var "@", ENVIRON[var]);
}
}