Hacker Newsnew | past | comments | ask | show | jobs | submit | more databasher's commentslogin

Why not use bash's printf %q?

   string=$(printf ' %q' "${array[@]}")


In Bash ≥ 4.4, you can also use parameter transformations:

    function quote() {
      echo "${@@Q}"
    }
(In both cases, the generated output is understood bash, but not necessarily by other POSIX-compliant shells.)


Pandoc calls these "Line blocks": https://pandoc.org/MANUAL.html#line-blocks


TCL had an amazing architecture for someone who was working in C. In C, you'd (1) create an instance of a TCL interpreter, (2) register your C functions with the TCL interpreter, and then (3) load scripts into the TCL interpreter. You'd do all your fast stuff in your C code, and just use the TCL for stitching together the high-level logic.


This, it is really easy to embed the tcl interpreter. Far easier than perl and python, even easier than lua.


Especially the commands were invoked command_name(argv, argc) and the thing was just like a CS 101 C program. Dead simple, and as they mentioned just used to orchestrate the fast stuff. You shouldn't make a command block a long time, but you could grab a handle to the output destination and set it up to stream output there from the C.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: