I'm having a weird issue with a Bash command where I get an error the first time I run a corrected command, but it works fine when I run it again using the up arrow. Here's what's going on:
1. I initially run the command `[[ 'a(' == *[(]* ]]`, which gives me a syntax error.
2. I then escape the open parenthesis and run `[[ 'a(' == *[(]* ]]`, but still get a different syntax error.
3. However, when I immediately rerun the last command using the up arrow, it executes perfectly and returns 0.
Why does the second command fail initially but work when I run it again? Also, if it helps, I've tried this on multiple systems, and it gives me the same result every time. Thanks for any insights!
2 Answers
It sounds like you might be dealing with some odd state in your Bash session. If the PS1 prompt shows up instead of PS2, that typically means that Bash thinks your command is complete. Just for clarity, try running your commands step by step, but maybe after hitting enter on the second one without the escape. That way, if there's an open quote or anything funky causing the error, you might catch it better. It’s strange that it won’t reproduce on another setup, so there might be something in your environment affecting it. Have you tried cleaning up any aliases or settings?
This one can be a bit tricky! The command with the escape should work, and I suspect that something might be lingering in your command history that affects how Bash interprets the commands. Just to confirm, you might want to check your environmental variables or even run your commands in a fresh terminal session. One thing I’d suggest is using just `[[ 'a(' == *(* ]]` to see if that makes a difference, but mostly just keep an eye on what gets entered when rerunning commands.
Related Questions
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically
[Centos] Delete All Files And Folders That Contain a String