bugGNU Screen - Bugs: bug #24133, Manpage instructions for dynamic...

 
 

bug #24133: Manpage instructions for dynamic titles should use printf rather than echo

Submitter:  None
Submitted:  Mon 25 Aug 2008 07:07:29 PM UTC
   
 
Category:  Documentation Severity:  2 - Minor
Priority:  * 3 - Low Status:  Confirmed
Privacy:  Public Assigned to:  thomasadam
Open/Closed:  Closed Release:  Cur Dev Sources
Fixed Release:  None Planned Release:  4.1.0
Work Required:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 27 Jan 2009 04:27:37 AM UTC, comment #4: 

e9090f3d6d719c1e15f21229c303628c7707fcba adds a fix for info.

Micah Cowan <micahcowan>
Mon 26 Jan 2009 01:30:28 AM UTC, comment #3: 

Partial fix with 24922dbc213ef4fb5860783eb18a2b0965973031, for man page. Need an equivalent change for the info page, and there may be other examples that need to be altered similarly.

Micah Cowan <micahcowan>
Mon 25 Aug 2008 08:12:24 PM UTC, comment #2: 

You're right, "echo -e" isn't valid under POSIX nor SUS.
Eventually, it would be nice to document a fully portable configuration for dynamic screen titles, or at least have examples for several different shells.

In the meantime, I think it's okay to add that little 0 to the manpage to save other people a few minutes of head scratching. The manpage example is already 100% specific to bash (it involves setting the PROMPT_COMMAND shell var, which isn't used by any other shells), and bash will always use its builtin echo over /bin/echo, and bash's builtin echo is guaranteed to accept -e and \0xxx.

Anyway, this is a pretty minor issue. However you guys choose to clean up the manpage is fine by me and appreciated.

Anonymous
Mon 25 Aug 2008 07:24:04 PM UTC, comment #1: 

\134 is a valid octal escape for C strings; it's strange that SUS specifies a leading 0. Must be due to historical implementations.

In actuality, though, the whole example is massively unportable, and POSIX and SUS both declare that it shouldn't work like that, even if you add the leading 0. POSIX and SUS both say that echo must not accept any options, but all operands must be accepted as literal strings to be output (except that POSIX, but not SUS, allows -n to have an implementation-defined meaning). SUS requires that backslash sequences be accepted, whether or not -e is specified (if it is, -e is supposed to be output literally).

In sum, using either options or backslashes in echo is incredibly unportable, and should not be recommended. Better to use printf in the example. Some older systems may lack printf, but at least it has far better-defined semantics than echo has.

Retitling this bug accordingly.

Micah Cowan <micahcowan>
Mon 25 Aug 2008 07:07:29 PM UTC, original submission:  

The "TITLES" chapter of the screen manpage instructs Bash users to set the shell variable PROMPT_COMMAND as follows:

   PROMPT_COMMAND='echo -n -e "\033k\033\134"'
   (I used "134" to output a '\' because of a bug in bash v1.04).

I agree that using the octal escape for a backslash is more portable than using \\.  Unfortunately, \134 is not a valid octal escape sequence; it should be \0134.  /bin/echo handles the invalid octal escape, but bash's builtin echo does not.

$ /bin/echo -e "Screen manpage says: \134   Should be: \0134"
Screen manpage says: \   Should be: \
$ /bin/echo --version | head -n 1
echo (GNU coreutils) 6.10

$ echo -e "Screen manpage says: \134   Should be: \0134"
Screen manpage says: \134   Should be: \
$ bash --version | head -n 1
GNU bash, version 3.2.33(1)-release (i686-pc-linux-gnu)


This bug doesn't evidence itself until you try to issue multiple escape sequences in a row (e.g., sending the null title escape right after a hardstatus update).

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by micahcowan (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-01-27 micahcowan Open/ClosedOpen Closed
    2008-08-25 micahcowan Severity3 - Normal 2 - Minor
        Priority5 - Normal 3 - Low
        StatusNone Confirmed
        Assigned toNone thomasadam
        Planned ReleaseNone 4.1.0
        SummaryManpage instructions for dynamic titles under bash use invalid octal escape Manpage instructions for dynamic titles should use printf rather than echo

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code