On Wed, Oct 25, 2017 at 11:21 PM, Alex Coffin <alexcoffin1...@gmail.com> wrote: [...] > Description: > Segmentation fault. I'm honestly not sure why. I was using batsh to > make a simple script. When I ran it generated a segfault. The segmentation > fault DOES NOT occur if "sleep" is replaced with "echo". > I also ran it on "GNU bash, version 4.4.12(1)-release > (x86_64-redhat-linux-gnu)" using codingground ( > https://www.tutorialspoint.com/execute_bash_online.php) the same issue > occurred. > > Repeat-By: > Run the following script (assuming you trust me lol): > function sleep { > local dur > dur="$1" > # if replaced with "echo" no segfault. > sleep ${dur}s > } > "sleep" $((5))
You are running the `sleep` function recursively, therefore exhausting the stack of the bash process. I believe you intended to do something like this instead: sleep() { command sleep "$.." }