From 4c71dcc491fde589abce47cb7855a54e3dbcd132 Mon Sep 17 00:00:00 2001 From: Tomek Mrugalski Date: Thu, 8 Aug 2019 16:45:17 +0200 Subject: [PATCH] [#201] Migrated script to /bin/sh, addresses shellcheck problems --- doc/sphinx/api/generate-templates | 33 ++++++++++++++++--------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/doc/sphinx/api/generate-templates b/doc/sphinx/api/generate-templates index 762bc1a687..ac1f0d6a58 100755 --- a/doc/sphinx/api/generate-templates +++ b/doc/sphinx/api/generate-templates @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # This script generates API documentation templates. # Usage: @@ -8,7 +8,7 @@ # File is expected to have a list of commands, one per line. # The templates will be created in api/ directory. -if (( $# != 1 )); then +if [ $# != 1 ]; then echo "Usage: ./generate-templates file" echo echo "File specifies a plain text file with each line having name of a command" @@ -21,24 +21,25 @@ mkdir -p api/ while read -r CMD; do F=api/$CMD.json - if [ -e $F ]; then + if [ -e "$F" ]; then echo "$F exists, skipping" continue; fi - echo "{" > $F - echo " \"name\": \"$CMD\"," >> $F - echo " \"brief\": \"a sentence or two explaining what this command does\"," >> $F - echo " \"description\": \"See \"," >> $F - echo " \"support\": [ \"undocumented\" ]," >> $F - echo " \"avail\": \"0.0.0\"," >> $F - echo " \"hook\": \"undocumented\"," >> $F + echo "{" > "$F" - echo " \"cmd-syntax\": \"Syntax of the command\"," >> $F - echo " \"cmd-comment\": \"Possibly some extra comments after the syntax.\"," >> $F + echo " \"name\": \"$CMD\"," >> "$F" + echo " \"brief\": [ \"a sentence or two explaining what this command does\" ]," >> "$F" + echo " \"description\": [ \"See \" ]," >> "$F" + echo " \"support\": [ \"undocumented\" ]," >> "$F" + echo " \"avail\": \"0.0.0\"," >> "$F" + echo " \"hook\": \"undocumented\"," >> "$F" - echo " \"resp-syntax\": \"Syntax of the response\"," >> $F - echo " \"resp-comment\": \"Optional extra comments after the resposne syntax.\"" >> $F - echo "}" >> $F + echo " \"cmd-syntax\": [ \"Syntax of the command\" ]," >> "$F" + echo " \"cmd-comment\": [ \"Possibly some extra comments after the syntax.\" ]," >> "$F" + + echo " \"resp-syntax\": [ \"Syntax of the response\" ]," >> "$F" + echo " \"resp-comment\": [ \"Optional extra comments after the resposne syntax.\" ]" >> "$F" + echo "}" >> "$F" echo "$CMD generated." -done < $1 +done < "$1" -- 2.47.2