summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfram Sang <wsa+renesas@sang-engineering.com>2019-01-23 20:07:07 +0100
committerWolfram Sang <wsa+renesas@sang-engineering.com>2019-01-23 21:23:42 +0100
commit54b6f6430b35d73507b0dcbfac9f85074c670e39 (patch)
tree6568a8d1417966a1c4225f52ec2252acea50cc11
parent6dc9b9c959d9d0f38d79b014afc7665a3a7e6537 (diff)
scripts/periupport_conv: refactor filename generation into seperate function
And don't produce useless '_' when generating filenames. Reported-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
-rwxr-xr-xscripts/periupport_conv9
1 files changed, 6 insertions, 3 deletions
diff --git a/scripts/periupport_conv b/scripts/periupport_conv
index 2a74007..aa1956d 100755
--- a/scripts/periupport_conv
+++ b/scripts/periupport_conv
@@ -9,6 +9,11 @@ DST="$2"
uuid_cmd="cat /proc/sys/kernel/random/uuid"
gawk -F: -v dst="$DST" -v cmd="$uuid_cmd" '
+ function make_filename(nam) {
+ gsub(/[: /]+/, "_", nam)
+ sub(/_$/, "", nam)
+ return nam
+ }
$1 == "B" {
bsp_id = $2
desc = substr($0, 46)
@@ -32,10 +37,8 @@ gawk -F: -v dst="$DST" -v cmd="$uuid_cmd" '
FS = " "
for (task in tasks) {
- nam = task
- gsub(/[: /]/, "_", nam)
cmd | getline uuid; close(cmd);
- F=dst "/" nam ".yaml"
+ F = dst "/" make_filename(task) ".yaml"
delete(sorted_idx)
asorti(tasks[task], sorted_idx)