From itsalldark at gmail.com Fri Jan 23 07:17:06 2009 From: itsalldark at gmail.com (Macro Chef) Date: Thu, 22 Jan 2009 22:17:06 -0700 Subject: odd behavior with v6.16 Message-ID: <1ec69a200901222117w612f3b56rede996cfa402268c@mail.gmail.com> We noticed this first with 6.16 as it does not occur in previous versions: nick at simba> more foo.csh #!/bin/tcsh -f @ var = 0129 + 1; echo $var nick at simba > ./foo.csh @: Badly formed number. nick at simba> more boo.csh #!/bin/tcsh -f @ var = 129 + 1; echo $var nick at simba > ./boo.csh 130 nick at simba> more coo.csh #!/bin/tcsh -f @ var = 012 + 1; echo $var orrie at simba > ./coo.csh 11 previous versions do not behave in this manner but act as one would expect, returning 130 in the first two cases and 13 in the last. I am sure I am missing something obvious here. Could someone enlighten me? Thanks. Nick From andersk at MIT.EDU Fri Jan 23 02:33:42 2009 From: andersk at MIT.EDU (Anders Kaseorg) Date: Thu, 22 Jan 2009 19:33:42 -0500 (EST) Subject: tcsh silently ignores the end of a script with no trailing newline Message-ID: balanced-tree:/tmp> printf 'echo hi\n' > file1 balanced-tree:/tmp> printf 'echo hi' > file2 balanced-tree:/tmp> tcsh file1 hi balanced-tree:/tmp> tcsh file2 This has caused confusion for users on a system with tcsh as the default shell, when they attempt to edit their dotfiles using editors that do not add a trailing newline by default. Anders From kim at tcsh.org Fri Jan 23 09:35:24 2009 From: kim at tcsh.org (Kimmo Suominen) Date: Fri, 23 Jan 2009 09:35:24 +0200 Subject: tcsh silently ignores the end of a script with no trailing newline In-Reply-To: References: Message-ID: <20090123073524.GV11650@kimmo.suominen.com> Tcsh should not execute characters in the buffer when it encounters an EOF. Just imagine that you were typing in a command to the prompt, when suddenly your connection to the host is broken. You don't want the incomplete command to be interpreted and executed. Normal text files, by definition, have newline characters at the end of each line, including the last one. You can probably configure your editor to work correctly. Best regards, + Kimmo -- Kimmo Suominen On Thu, Jan 22, 2009 at 07:33:42PM -0500, Anders Kaseorg wrote: > balanced-tree:/tmp> printf 'echo hi\n' > file1 > balanced-tree:/tmp> printf 'echo hi' > file2 > balanced-tree:/tmp> tcsh file1 > hi > balanced-tree:/tmp> tcsh file2 > > This has caused confusion for users on a system with tcsh as the default > shell, when they attempt to edit their dotfiles using editors that do not > add a trailing newline by default. > > Anders From kim at tcsh.org Fri Jan 23 09:40:35 2009 From: kim at tcsh.org (Kimmo Suominen) Date: Fri, 23 Jan 2009 09:40:35 +0200 Subject: odd behavior with v6.16 In-Reply-To: <1ec69a200901222117w612f3b56rede996cfa402268c@mail.gmail.com> References: <1ec69a200901222117w612f3b56rede996cfa402268c@mail.gmail.com> Message-ID: <20090123074035.GW11650@kimmo.suominen.com> Numbers beginning with zero are octal, not decimal. Best regards, + Kimmo -- Kimmo Suominen On Thu, Jan 22, 2009 at 10:17:06PM -0700, Macro Chef wrote: > We noticed this first with 6.16 as it does not occur in previous versions: > > nick at simba> more foo.csh > #!/bin/tcsh -f > @ var = 0129 + 1; > echo $var > > nick at simba > ./foo.csh > @: Badly formed number. > > > nick at simba> more boo.csh > #!/bin/tcsh -f > @ var = 129 + 1; > echo $var > > nick at simba > ./boo.csh > 130 > > nick at simba> more coo.csh > #!/bin/tcsh -f > @ var = 012 + 1; > echo $var > > orrie at simba > ./coo.csh > 11 > > previous versions do not behave in this manner but act as one would expect, > returning 130 in the first two cases and 13 in the last. I am sure I am > missing something obvious here. Could someone enlighten me? Thanks. > > Nick From andersk at MIT.EDU Fri Jan 23 10:12:49 2009 From: andersk at MIT.EDU (Anders Kaseorg) Date: Fri, 23 Jan 2009 03:12:49 -0500 (EST) Subject: tcsh silently ignores the end of a script with no trailing newline In-Reply-To: <20090123073524.GV11650@kimmo.suominen.com> References: <20090123073524.GV11650@kimmo.suominen.com> Message-ID: On Fri, 23 Jan 2009, Kimmo Suominen wrote: > Just imagine that you were typing in a command to the prompt, when > suddenly your connection to the host is broken. You don't want > the incomplete command to be interpreted and executed. Correct. That?s why my report is about scripts, not interactive use. This problem most commonly bites our users on files like ~/.tcshrc. > Normal text files, by definition, have newline characters at the > end of each line, including the last one. You can probably configure > your editor to work correctly. Whether all text files must be newline-terminated is a matter of debate, but it is true that tcsh has every right to believe that all valid tcsh scripts must be. In that case, tcsh should display a syntax error if it encounters a script that is not properly terminated, just as with any other invalid script, rather than silently discarding the trailing characters. That would be enough for a confused user to figure out what went wrong. Anders