There are so many '\' in it, which dazzles me. It this a good style
of shell script?
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.
It this a good style of shell script?
Regards,
HZ
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. It this a good style of shell script?
Regards,
HZ
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 113 |
Nodes: | 8 (1 / 7) |
Uptime: | 70:31:14 |
Calls: | 2,472 |
Calls today: | 1 |
Files: | 8,642 |
Messages: | 1,899,887 |