Comments on: Strange feature in bash script https://blog.ciberterminal.net/2011/09/22/strange-feature-in-bash-script/ Welcome, connect your terminal Mon, 15 Jul 2019 09:29:51 +0000 hourly 1 https://wordpress.org/?v=6.8.1 By: dodger https://blog.ciberterminal.net/2011/09/22/strange-feature-in-bash-script/comment-page-1/#comment-80 Thu, 22 Sep 2011 18:55:00 +0000 http://blog.ciberterminal.net/?p=553#comment-80 This remember me a lot the nginx’s wiki page “if is evil“:

The question is why sometimes bash calls a new sub-shell and other times it works as the common way?

]]>
By: Dani https://blog.ciberterminal.net/2011/09/22/strange-feature-in-bash-script/comment-page-1/#comment-79 Thu, 22 Sep 2011 16:23:43 +0000 http://blog.ciberterminal.net/?p=553#comment-79 sub shells are evil!

Try this way.
[cc lang=”bash”]
#!/bin/bash
let x=0
while read LINE
do
[[ “${LINE}” =~ ^(a|c|d)$ ]] && AUX[$x]=${BASH_REMATCH[1]} && let x++

done< <(echo -e "a\nb\nc\nd") echo ${AUX[@]} [/cc]

]]>