[kwlug-disc] Sanity check of shell scripting approach
Mikalai Birukou
mb at 3nsoft.com
Wed Apr 21 13:48:38 EDT 2021
> It would be helpful if you give a short example, like
> jq .appDomain < file
Example is below in the original message. I guess, I wonder how mixing
smells to other.
>> Sometimes, while in shell, I want to do manipulations that are simple
>> in node, and I have no idea how to do in shell. I find myself with
>> functions like:
>>
>> app_domain_from_manifest() {
>> local manifest="$1"
>> node -e "
>> const m = fs.readFileSync('$manifest', { encoding: 'utf8' });
>> const appDomain = JSON.parse(m).appDomain.trim();
>> if (!appDomain) { throw new Error('appDomain field is not a
>> string'); }
>> console.log(appDomain);
>> " || exit $?
>> }
>>
>> Couple of lines passed to node -e.
>>
>> Is it insane?
>>
>> Do you do similar with python?
>>
>> What's your milage?
More information about the kwlug-disc
mailing list