mrbaseman / parse_yaml

a simple yaml parser implemented in bash
GNU General Public License v3.0
165 stars 37 forks source link

Duplicate BASH script to POSIX shell. #11

Open WhyIsEvery4thYearAlwaysBad opened 2 years ago

WhyIsEvery4thYearAlwaysBad commented 2 years ago

bash is not a portable shell, unlike sh, so it'd be nice if the script could run on just the bourne shell.

mrbaseman commented 2 years ago

well, if I'm not mistaken, it's really not much to change as most of the code is sed and awk. Just replace

function parse_yaml {
   local prefix=$2
   local separator=${3:-_}
   local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=${fs:-$(echo @|tr @ '\034')} i=${i:-  }

by

parse_yaml () {
prefix=$2
separator=${3:-_}
s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=${fs:-$(echo @|tr @ '\034')} i=${i:-  }

i.e. drop the keywords function and local. Could you give it a try?