• Re: Terrible frightening function defined in the intel oneapi toolkits

    From Grant Taylor@21:1/5 to hongy...@gmail.com on Thu Dec 30 16:13:48 2021
    On 12/30/21 3:47 PM, hongy...@gmail.com wrote:
    There are so many '\' in it, which dazzles me. It this a good style
    of shell script?

    I would not call it /good/ by any stretch of the imagination.

    Sometimes it's /necessary/ to do things like that.

    The eight (8) backslashes tell me that it's an escape of an escape of an
    escape of an escape.

    1st: \
    2nd: \\
    3rd: \\\\
    4th: \\\\\\\\

    The thought of needing four levels of escaping makes me shudder. I
    would think that there would have to be a better way to do what's being
    done.



    --
    Grant. . . .
    unix || die

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to hongy...@gmail.com on Fri Dec 31 13:12:50 2021
    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)
  • From Wayne@21:1/5 to hongy...@gmail.com on Fri Dec 31 16:38:59 2021
    On 12/30/2021 5:47 PM, 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. It this a good style of shell script?

    Regards,
    HZ



    Merely 8 escapes? You should take a look at old nroff/troff macros;
    I remember seeing 64 backslashes. Sadly, sometimes there is no
    great alternative.

    --
    Wayne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)