On 30.12.2021 23:47,
hongy...@gmail.com wrote:
I use lmod to generate the corresponding module files of Intel oneapi, and find the following code snippets in the result:
werner@X10DAi-00:/opt/intel/oneapi$ sh_to_modulefile setvars.sh
[...]
set_shell_function("save_args"," \
for arg in \"$@\";\
do\
printf \"%s\\n\" \"$arg\" | sed -e \"s/'/'\\\\\\\\''/g\" -e \"1s/^/'/\" -e \"\\$s/\\$/' \\\\\\\\/\";\
done;\
echo \" \"\
","")
There are so many '\' in it, which dazzles me.
This looks like shell code that is just _embedded_ in some *other*
language. Try a newsgroup/forum of *that* language to get an answer!
It this a good style of shell script?
Of course not. But the horrific number of '\' is not (not alone) a
shell question in this context.
I suggest to remove the unnecessary escapes at the outer level to
create pure (functional correct) shell code and then post this code
to see where there's potential for optimization or use of other tools.
Janis
Regards,
HZ
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)