correctly merge and reformat custom json into generated config
Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
		
					parent
					
						
							
								31dddca0db
							
						
					
				
			
			
				commit
				
					
						c3bf4c7b61
					
				
			
		
					 1 changed files with 4 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -126,10 +126,10 @@ if [ -f "$__object/parameter/json-config" ]; then
 | 
			
		|||
   if [ "$json_config" = "-" ]; then
 | 
			
		||||
      json_config="$__object/stdin"
 | 
			
		||||
   fi
 | 
			
		||||
   printf ','
 | 
			
		||||
   # remove trailing ,
 | 
			
		||||
   json=$(cat "$json_config")
 | 
			
		||||
   echo "${json%*,}"
 | 
			
		||||
   # remove leading and trailing whitespace and commas from first and last line
 | 
			
		||||
   # indent each line with 3 spaces for consistency
 | 
			
		||||
   json=$(sed -e 's/^[ \t]*/   /' -e '1s/^[ \t,]*//' -e '$s/[ \t,]*$//' "$json_config")
 | 
			
		||||
   printf '   ,%s\n' "$json"
 | 
			
		||||
fi
 | 
			
		||||
echo "}"
 | 
			
		||||
) | \
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue