I have simple question but it's annoying me ..
who don't know ,js-beautify is a library to make ugly stinky js files more readable and beauty ,hence the name ;D
when I do $ js-beautify somefile.js in bash ,every thing is good and the output is clean as expicted ,but when I try to store that output in a variable readable=$(js-beautify somefile.js) then echo $readable ,nothing changed !! like I didn't use js-beautify at all !!
what's the problem here ?
Echo the variable with double quotes:
echo "$readable"That should give you proper EOLs/newlines. (Also see BASH "Double Quotes").
Please note that many blocks of code may not 'expand'/prettify. To test command line output in shell versus online, run it in BASH shell and check it against results here: https://beautifier.io
(It's the same version my pip installed for python/bash use.)
Also see:
Capturing multiple line output into a Bash variable
PS (to your comment above on question):
To properly install the Python3
pipversion, the command is actually:pip3 install jsbeautifier(Or, 'pip'. But, notjs-beautify- that's the shell command.)