bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: semicolon at beginning of line


From: Elliott Forney
Subject: Re: semicolon at beginning of line
Date: Mon, 9 Apr 2012 22:03:46 -0600

Here is another example that appears to defy my expectations.  In this
case, the semicolon is allowed:

sine:~$ hello='echo hello'
sine:~$ world='echo world'
sine:~$ ${hello};${world}
hello
world
sine:~$ unset hello
sine:~$ ${hello};${world}
world
sine:~$ unset world
sine:~$ ${hello};${world}

Thanks!
  Elliott Forney

On Mon, Apr 9, 2012 at 10:02 PM, Elliott Forney
<address@hidden> wrote:
> Sure, a comment can be used to place a line in your history but that
> doesn't really address the examples I had.  Just seems to me like a
> lone semicolon could be treated as a newline/noop.  I can't seem to
> think of anything that this would break but, of course, that doesn't
> mean it wouldn't.  The end of a case in a switch statement is
> certainly an interesting one, hadn't thought of that, but it should be
> possible to handle that by checking for ;; as a token before ;.
>
> I might mention that ksh, zsh and tcsh all allow lines to begin with a
> semicolon.  zsh even allows "; ; ; echo hello world ; ; ;" although
> ksh only allows a single ; at the beginning of a line.
>
> On Sun, Apr 8, 2012 at 6:48 PM, Joseph Fredette <address@hidden> wrote:
>> Could also use a #, no?
>>
>> On Sun, Apr 8, 2012 at 8:46 PM, Steven W. Orr <address@hidden> wrote:
>>
>>> On 4/7/2012 4:00 PM, Elliott Forney wrote:
>>>
>>>> I wish bash would happily execute lines that begin with a semicolon,
>>>> i.e., treat it as a no-op followed by a command.  The following
>>>> examples come to mind:
>>>>
>>>> $ infloop&  echo hello
>>>> [2] 11361
>>>> hello
>>>> $ infloop&; echo hello
>>>> bash: syntax error near unexpected token `;'
>>>>
>>>> $ echo hello; echo world
>>>> hello
>>>> world
>>>> $ echo hello;; echo world
>>>> bash: syntax error near unexpected token `;;'
>>>>
>>>> $ ; echo hello world
>>>> bash: syntax error near unexpected token `;'
>>>>
>>>> Any thoughts?
>>>>
>>>> Thanks,
>>>>   Elliott Forney
>>>>
>>>
>>> Just use a colon.
>>>
>>> : echo Hello world.
>>>
>>> I use it all the time to 'park' a command in my history. Then when I'm
>>> ready, I just back up to it and remove the colon.
>>>
>>>
>>> --
>>> Time flies like the wind. Fruit flies like a banana. Stranger things have
>>>  .0.
>>> happened but none stranger than this. Does your driver's license say Organ
>>> ..0
>>> Donor?Black holes are where God divided by zero. Listen to me! We are all-
>>> 000
>>> individuals! What if this weren't a hypothetical question?
>>> steveo at syslang.net
>>>
>>>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]