4 ms·
It's the read/readarray builtin that's creating the tmpfiles and that's not great, but the string substitution doesn't. My point was there's no need to call out
by jmcnulty 5y ago
It's the read/readarray builtin that's creating the tmpfiles and that's not great, but the string substitution doesn't. My point was there's no need to call out to another program to do something that bash is capable of doing itself.
- chubot 5y agoNo, it's the here doc, including here strings. See the blog post, which doesn't use read or readarray.
- deleted 5y ago[deleted]
- jmcnulty 5y agoUnderstand. Did some quick tests myself and see what you mean. Here's a version that doesn't use "here string" and so doesn't create temporary files. #!/bin/bash shopt -s lastpipe string="Los Angeles, London, Belfast, New York" echo "${string/, /,}" | readarray -d, -t arrayA echo ${arrayA[0]} echo ${arrayA[1]} Also, the lastpipe option runs the readarray in the context of the current process.