jjd@BBN.COM (James J Dempsey) (07/11/89)
I'm running bash 1.02 under Ultrix 3.0 on a VAX 8530 compiled with GCC 1.35. The "-n" option of the builtin echo doesn't seem to suppress a newline at the end. However, using \c with -e does seem to suppress the newline. I couldn't figure out the problem from a quick look at the code since -n and \c seem to do the same thing. The -n option worked fine in 1.01 but it looks like the argument parsing for echo_builtin has changed since then. $ echo foo foo $ echo -n foo foo $ echo -e 'foo\c' foo$ --Jim Dempsey-- BBN Communications jjd@bbn.com (ARPA Internet) ..!{decvax, harvard, wjh12, linus}!bbn!jjd
bfox@AUREL.CALTECH.EDU (Brian Fox) (07/11/89)
Date: Mon, 10 Jul 89 18:40:46 -0400 From: James J Dempsey <jjd@bbn.com> I'm running bash 1.02 under Ultrix 3.0 on a VAX 8530 compiled with GCC 1.35. The "-n" option of the builtin echo doesn't seem to suppress a newline at the end. However, using \c with -e does seem to suppress the newline. I couldn't figure out the problem from a quick look at the code since -n and \c seem to do the same thing. Yeah, sorry about that. In builtins.c, function echo_builtin (), the segment of code reading: while (*temp) { if (*temp == 'n') display_return == 0; #ifdef V9_ECHO else if (*temp == 'e') should read: while (*temp) { if (*temp == 'n') display_return = 0; #ifdef V9_ECHO else if (*temp == 'e') i.e., the test "display_return == 0" should be an assignment. brian
chet@kiwi.CWRU.EDU (Chet Ramey) (07/11/89)
In article <8907102240.AA00404@life.ai.mit.edu> jjd@BBN.COM (James J Dempsey) writes: >The "-n" option of the builtin echo doesn't seem to suppress a newline >at the end. However, using \c with -e does seem to suppress the >newline. I couldn't figure out the problem from a quick look at the >code since -n and \c seem to do the same thing. It's a typo. Here's a diff for it which also fixes another bug in the echo builtin (your line numbers may vary): *** bash-1.02/builtins.c Wed Jul 5 21:25:49 1989 --- src-1.02/builtins.c Mon Jul 10 18:51:00 1989 *************** *** 980,984 **** { if (*temp == 'n') ! display_return == 0; #ifdef V9_ECHO else if (*temp == 'e') --- 981,985 ---- { if (*temp == 'n') ! display_return = 0; #ifdef V9_ECHO else if (*temp == 'e') *************** *** 1021,1027 **** case '4': case '5': case '6': case '7': c -= '0'; ! if (*s >= 0 && *s <= '7') c = c * 8 + (*s++ - '0'); ! if (*s >= 0 && *s <= '7') c = c * 8 + (*s++ - '0'); break; --- 1022,1028 ---- case '4': case '5': case '6': case '7': c -= '0'; ! if (*s >= '0' && *s <= '7') c = c * 8 + (*s++ - '0'); ! if (*s >= '0' && *s <= '7') c = c * 8 + (*s++ - '0'); break; Chet Ramey Chet Ramey "We are preparing to think about contemplating Network Services Group, CWRU preliminary work on plans to develop a chet@cwjcc.INS.CWRU.Edu schedule for producing the 10th Edition of the Unix Programmers Manual." -- Andrew Hume