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: | 285 |
Nodes: | 16 (2 / 14) |
Uptime: | 67:47:53 |
Calls: | 6,488 |
Calls today: | 1 |
Files: | 12,096 |
Messages: | 5,275,268 |