🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Dan Jacobson Wed, 19 Aug 1992 20:05
I want # to be my interactive comment character; histchars bitch
#906
Author: Dan Jacobson
Date: Wed, 19 Aug 1992 20:05
103 lines
4997 bytes
[Bash 1.12] I want # to be my interactive comment character, so
I will get this:

bash$ echo bla # pla
bla

at the same time, I don't want to "enjoy" any "!" expansion (so, yes, I do
set +o histexpand
and, yes, it does work.  No complaint about this).

Now, about getting # to be my interactive comment character,
First, we see under
bash$ help
|Type `help name' to find out more about the function `name'.
|Use `info bash' to find out more about the shell in general.
[by the way, you should add a note saying that "info" might not be
installed at every site.]
[...]
bash$ help Variables
|    histchars       Characters controlling history expansion and quick
|               substitution.  The first character is the history
|               substitution character, usually `!'.  The second is
|               the `quick substition' character, usually `^'.
no mention of comment characters here.  Plus the final "substition" is
misspelled...[one of the Markowitz keywords that when misspelled may
indicate stress during childhood :-)]

$ man bash
|     histchars
|          The two characters which control history expansion  and
|          tokenization.   The  first  character  is  the  history
|          expansion character, that is, the character which  sig-
|          nals  the  start  of a history expansion, normally `!'.
|          The second character is the character  which  signifies
|          that the remainder of the line is a comment, when found
|          as the first character of a word.
ah ha... a different meaning for the second character!  shame shame.
But no word on how to assign that second character without also
assigning a first character, and thus bringing on "! expansion
pleasure" :-( , [perhaps set +o histexpand would then be the official
recommended way of re-nullifying that hopefully...] but, ah, dear
friends, the plot thickens:

bash$ cat bash-1.12/documentation/features.texi
|@vindex histchars
|@item histchars
|Up to three characters which control history expansion, quick
|substitution, and tokenization.  The first character is the
|@dfn{history-expansion-char}, that is, the character which signifies the
|start of a history expansion, normally `!'.  The second character is the
|character which signifies `quick substitution' when seen as the first
|character on a line, normally `^'.  The optional third character is the
|character which signifies the remainder of the line is a comment, when
|found as the first character of a word, usually `#'.
still another definition! We're talking "anti family values", dear
friends :-)  And again, no word on how to assign the third character with
out tripping off the first two...  Indeed, when one looks at
bash-1.12/subst.c, one sees code reminiscent of features.texi's
version of the story.


Plus, I tried using various combos of the above, and could not turn on
my interactive comment character, though the evil "!" expansion stuff
did come back to life...

There are tons of times when I want to
bash$ do some command #with the back half commented out
bash$ #or even the whole thing commented out
in an interactive shell.  Therefore my needs are justified and I would
like to see how one does it in bash 1.12.  Hmmm?

A further bitch about the man page:
|COMMENTS
|     In a non-interactive shell, a word beginning with  #  causes
|     that  word  and  all remaining characters on that line to be
|     ignored.
in the _same spot in the manual_, you should tell folks how to turn # on
for interactive shells.

Plus, saying "a word beginning with #" implies that
rm -rf bla # /
will get different treatment than
rm -rf bla #/

Too bad if other leading brand shells have the same "word" mistake in
their man pages.

If you fix the "COMMENTS" part of the man page, you would also want to
fix this part of the man page:

$ man bash
|     histchars
|          The two characters which control history expansion  and
|          tokenization.   The  first  character  is  the  history
|          expansion character, that is, the character which  sig-
|          nals  the  start  of a history expansion, normally `!'.
|          The second character is the character  which  signifies
|          that the remainder of the line is a comment, when found
|          as the first character of a word.
                  ^^^^^^^^^^^^^^^^^^^^^^^^^
-- 
danj1@ihspa.att.com (Dan Jacobson) Naperville IL USA
+17089796364 Chinese~{;}5$Da~}Ji1Dan1ni2
Re: I want # to be my interactive comment character; histchars bitch
#912
Author: Robert Elz
Date: Sun, 23 Aug 1992 15:29
44 lines
2413 bytes
In <1992Aug19We160535a.danj1@ihspa.att.com> danj1@ihspa.ATt.COM (Dan Jacobson) writes:

| [Bash 1.12] I want # to be my interactive comment character, so
| I will get this:

I suspect this isn't possible - I believe bash only does commenting when
its not interactive.

You're right that the doc isn't consistent, and thus isn't correct.

| still another definition! We're talking "anti family values", dear
| friends :-)  And again, no word on how to assign the third character with
| out tripping off the first two...  Indeed, when one looks at
| bash-1.12/subst.c, one sees code reminiscent of features.texi's
| version of the story.

I'm not sure that the third char in histchars is really related to
what you want - but if your problem is that you want to set it without
setting anything in histchars[0] and histchars[1], then what is probably
the best way is to set those first two to some character that has a higher
priority meaning (ie: one interpreted and removed before history) so
that its unlikely (though not completely impossible) that you'll ever
enter one - certainly the meaning of ! would be disabled.

eg: histchars='^m^m#'

(which is typed as "histchars='^V^M^V^M#'" assuming you use vi
style editing - probably some other way if you inflict emacs upon
yourself).   ^M (ie: carriage-return) is not normally going to still be
there in an input line by the time history expansions are looked at.

| Plus, saying "a word beginning with #" implies that
| rm -rf bla # /
| will get different treatment than
| rm -rf bla #/

I have no idea what you're getting at here, a # alone is just
a single character word that starts with # - remember that "word"
here is used in the technical case of the shell, which is any
sequence of characters not including any shell delimiters, or
any of those delimiters - so abc is a word, as is 123, or @@@
or #abc or #

kre
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads