6

I'm using rxvt-unicode, version 9.22, as a terminal emulator, and configure it with the file ~/.Xresources.

When I modify the configuration file, to see the effects immediately I execute the command:

xrdb ~/.Xresources

From man xrdb:

Lines that begin with an exclamation mark (!) are ignored and may be used as comments.

On my machine, with xrdb version 1.1.0, when a commented line contains an odd number of single quotes, for example ! it's a comment, xrdb complains with an error such as:

/home/user/.Xresources:1:5: warning: missing terminating ' character
 ! it's a comment
     ^

Currently, I double the single quotes to avoid this error:

! it''s a comment

I think I could also use /* */, instead of !, because it's the comment string used by default by Vim (defined in $VIMRUNTIME/ftplugin/xdefaults.vim). But I would prefer using !, because I find comments a little more readable with it.

Is there a way to ask xrdb to ignore single quotes inside the commented lines of ~/.Xresources?

user547381
  • 273
  • 3
  • 9
  • 2
    xrdb is using the C preprocessor, which is (a) why it complains about quotes and (b) recognizes C-style comments. – Thomas Dickey Jun 24 '17 at 21:52
  • 2
    This seems to be due to a change in the default behavior of GNU `cpp`. See [The C Preprocessor: 10.1 Traditional lexical analysis](https://gcc.gnu.org/onlinedocs/cpp/Traditional-lexical-analysis.html#Traditional-lexical-analysis). At least on my current system (Ubuntu 16.10) the warning goes away if you use `xrdb -cpp "/usr/bin/cpp -traditional-cpp"` or `xrdb -cpp "/usr/bin/cpp -traditional"` explicitly. – steeldriver Jun 24 '17 at 21:55
  • @ThomasDickey Thank you very much for the explanation. @steeldriver Thank you, your command works on my system too (Ubuntu 16.04). I could create an alias for it, for an interactive use. However, I don't know what happens at boot time. When the X session starts, should I configure something so that `~/.Xresources` is read with `xrdb` using the option `-cpp`? Anyway, the command works, so if you post it as an answer I'll accept it. Thank you very much. – user547381 Jun 24 '17 at 22:01

2 Answers2

7

This seems to be due to a change in the default behavior of GNU cpp, which xrdb uses as its default preprocessor. Specifically, according to The C Preprocessor: 10.1 Traditional lexical analysis:

Generally speaking, in traditional mode an opening quote need not have a matching closing quote.

However cpp provides a command line option to operate in traditional mode:

-traditional
-traditional-cpp
    Try to imitate the behavior of pre-standard C preprocessors, as opposed to ISO 
    C preprocessors. See Traditional Mode.

while xrdb allows the preprocessor to be defined explicitly on its command line:

-cpp filename
       This  option  specifies the pathname of the C preprocessor pro‐
       gram to be used.  Although xrdb was designed to  use  CPP,  any
       program  that  acts  as a filter and accepts the -D, -I, and -U
       options may be used.

Hence it should be possible to suppress the warning by using

xrdb -cpp "/usr/bin/cpp -traditional-cpp"  ~/.Xresources

or

xrdb -cpp "/usr/bin/cpp -traditional"  ~/.Xresources
steeldriver
  • 78,509
  • 12
  • 109
  • 152
0

I worked around the error by replacing single quotes (') with Unicode apostrophes (’) in .Xresources comments.

There are other Unicode options, if the apostrophe doesn't suit you.