From tateusg at hotmail.com Wed Mar 26 13:15:31 2025 From: tateusg at hotmail.com (Matheus Garcia) Date: Wed, 26 Mar 2025 13:15:31 +0000 Subject: [Tcsh] Interactive comments for tcsh? In-Reply-To: References: Message-ID: https://github.com/tcsh-org/tcsh/pull/89/files/e59e30adb28b683f5f46f5b66bedfe1d6366e7d4#diff-3c3be7038187eac587a847863d11413dc3111f2fb82c8e0785227287961e8a1bR280 Refactored. const-qualified variables yield undefined behavior on change. Do pointer struct members follow this behavior as well? Possible undefined behavior case? @@ -273,9 +274,21 @@ syn0(const struct wordent *p1, const struct wordent *p2, int flags) t->t_dcar = t1; t->t_dcdr = syntax(p, p2, flags); return (t); + + case '#': + if (intty) { + struct wordent *p1 = p2->prev; + + p1 = p1->prev = p1->prev->prev; + xfree(p1->next->word); + xfree(p1->next); + p1->next = p2->prev; + goto out; + } default: break; } +out: if (l == 0) return (syn1(p1, p2, flags)); seterror(ERR_TOOMANYLP); ________________________________ https://github.com/Krush206/tcsh/commit/70eec821e7965cfa728277e00d12a174829abc82 This should do to prevent history substitution. Only problem is that adds a new backslash for ! characters. ________________________________ https://github.com/Krush206/tcsh/commit/93f08ae2b63073ba57125bbb2be375e7c78cdaa5 I modified the parser so that # characters are ignored. Unfortunately, history substitution still is parsed, because it's executed before syntax(). History substitution is probably located in sh.lex.c, and the code is executed before syntax(). ________________________________ Is there any possibility/interest in adding an 'interactive_comments" option for tcsh like is in bash? I'm interested because I often make notes of procedures/commands that I want to cat and paste into the terminal to repeat at some point and want to be able to add comments to them. Stuff like: mkdir foobar # pick any name cd foobar ln -s ../bletch/bin/* ./ # include bletch commands I have been using ' ;: ' to introduce comments, but the shell still tries to parse the rest of the line and if there are any quotes, semi-colons, less-thans, or greater-thans, it doesn't work properly -WRSomsky -------------- next part -------------- An HTML attachment was scrubbed... URL: