Wednesday, May 15, 2024
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 5906  / 3 Years ago, fri, june 11, 2021, 1:17:00

So tab completion is great... unless you're a n00b... and you type the first part of ifconfig and then hit tabenter real quick... in which case you end up with:



(not actual terminal input)



~$ if
>
>
>'
> "
> end
> ^C
>
> )
> ()
> ]
>
> []
> ]
> ;
>
>
> []
> ;aognf'
>
>


What's really weird is ctrlc didn't even work. I know about quotation marks (which is why that's what I tried first), but that knowledge didn't help.



How can I break out of one of these fat-fingered mistakes next time, without closing the terminal?



Bonus point for answering what is this thing that I've accidentally started doing?


More From » command-line

 Answers
0

You have started an if statement. The next command is run, and only if it returns a zero exit status (success) are the following commands executed, from the then keyword up until the fi keyword ("if" backwards). Like:



if true
then
echo yes
fi


Typically one uses the test program (AKA [) to test various things such as:



if [ $somevariable = someword ]


or



if [ -f /some/file/exists ]


A Ctrl-C aborts it fine for me.


[#26545] Friday, June 11, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aradxalte

Total Points: 70
Total Questions: 116
Total Answers: 116

Location: Dominica
Member since Sat, Nov 5, 2022
2 Years ago
;