bugGNU roff - Bugs: bug #61040, [nroff]: verbose_option_works.sh:...

 
 

bug #61040: [nroff]: verbose_option_works.sh: confounded by environment variables

Submitter:  Bjarni Ingi Gislason <bjarniig>
Submitted:  Sat 14 Aug 2021 12:17:26 AM UTC
   
 
Category:  Core Severity:  3 - Normal
Item Group:  Test Status:  Fixed
Privacy:  Public Assigned to:  gbranden
Open/Closed:  Closed Planned Release:  1.23.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 23 Aug 2021 04:25:26 AM UTC, comment #6: 


commit 2584cf24062a61e94a452b960c24837522af4fef
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Sat Aug 21 14:11:15 2021 +1000

    [tests]: Make robust to environment settings.

    * src/roff/groff/tests/use_point_size_escape_with_single_digit_arg.sh:
    * src/roff/nroff/tests/verbose_option_works.sh:
    * tmac/tests/s_IP-indents-using-paragraph-type-size.sh: Export empty
      $LESSCHARSET and $GROFF_TYPESETTER to the environment.

    Fixes <https://savannah.gnu.org/bugs/?61040>.  Thanks to Bjarni Ingi
    Gislason for the report.


G. Branden Robinson <gbranden>
Group administrator
Sat 21 Aug 2021 11:28:36 PM UTC, comment #5: 


comment #4:

>   I don't have "GROFF_TYPESETTER" in my environment.
>
>   The "locale charmap" after the "exec ..." shows "ISO-8859-1".
>
>   The outcome of "LC_ALL=C locale charmap" is "ANSI_X3.4-1968".
>
>   I have LESSCHARSET defined as "latin1".
>


Thanks for the follow-up, Bjarni.  I forgot about LESSCHARSET, so this test script needs to sanitize that variable as well.

G. Branden Robinson <gbranden>
Group administrator
Sat 21 Aug 2021 05:54:10 PM UTC, comment #4: 

  I don't have "GROFF_TYPESETTER" in my environment.

  The "locale charmap" after the "exec ..." shows "ISO-8859-1".

  The outcome of "LC_ALL=C locale charmap" is "ANSI_X3.4-1968".

  I have LESSCHARSET defined as "latin1".

Bjarni Ingi Gislason <bjarniig>
Sat 21 Aug 2021 02:19:32 AM UTC, comment #3: 

comment #2:

>   The test failed with "-Tlatin1" being different from "-Tascii".


How did you manage to cause this to happen?  I would have thought the LC_ALL=C on line 22 would have prevented this...Ah, I see, you probably have GROFF_TYPESETTER=latin1 in your environment.  I'll close that avenue for confoundation of the test.

>   So I thought the "-T" option was the test.


The name of the file says that it is a test of the verbose option (-V); it is not a test of the operation of the -T option.

>   Now looking at the content of the test,
> it is now evident to me,
> that the real test is to find out
> if the used shell resolves correctly the parameter expansion
> '${1+"$@"}'


The name of the file says that it is a test of the verbose option (-V); it is not a test of the underlying shell.  The test is there to make sure that we construct the groff command line as we expect to even if the command operands are unusual.  If the shell fails to expand parameters as we expect, then we either have to alter nroff.sh to accommodate its behavior, or disclaim support for that shell.

>   I see two solutions
>
> 1) add "-Tascii" to the nroff command
>
> 2) add " -- " after the options to "nroff"
>    change the "sedexpr" to '^.* -- ' and the testing string for "groff"
> accordingly.


I don't understand what problem you are trying to solve here.  I assume one of the ones above which are expressly outside the mission of the test script.

>   A test for invalid arguments to the "-T" option is missing,
> otherwise a value from the environment is supplied without telling the
> user.


The test script (for the verbose option working) doesn't do this, but nroff itself has clearly documented semantics.

From the nroff(1) man page:

       Consequently, acceptable arguments to the -T option are ascii,
       latin1, utf8, and cp1047; any others are ignored.  If neither the
       GROFF_TYPESETTER environment variable nor the -T command-line
       option (which overrides the environment variable) specifies a
       (valid) device, nroff consults the locale to select an
       appropriate output device.  It first tries the locale(1) program,
       then checks several locale-related environment variables; see
       section “Environment”, below.  If all of the foregoing fail,
       -Tascii is implied.


Your troubles with this script have arisen from (1) your commitment to a legacy ISO 8859 character encoding in your terminal environment (that's fine, if a bit hidebound, and a configuration we should support) and (2) my failure to anticipate the test being run in an environment where GROFF_TYPESETTER was set.  As noted above, I'll fix that.

G. Branden Robinson <gbranden>
Group administrator
Tue 17 Aug 2021 10:10:22 PM UTC, comment #2: 

  The test failed with "-Tlatin1" being different from "-Tascii".

  So I thought the "-T" option was the test.

  Now looking at the content of the test,
it is now evident to me,
that the real test is to find out
if the used shell resolves correctly the parameter expansion
'${1+"$@"}'

  I see two solutions

1) add "-Tascii" to the nroff command

2) add " -- " after the options to "nroff"
   change the "sedexpr" to '^.* -- ' and the testing string for "groff"
accordingly.

N.B.

  A test for invalid arguments to the "-T" option is missing,
otherwise a value from the environment is supplied without telling the
user.

Bjarni Ingi Gislason <bjarniig>
Mon 16 Aug 2021 04:59:30 PM UTC, comment #1: 

Hi Bjarni,

I don't agree.  This is not a general-purpose program, but a unit test.  Such things are seldom looked at unless there is trouble.  In such a scenario, having literal content in the test case makes it quickly clear what is expected.

In my opinion, the style is a time saver.

If someone else contributes test cases or cares to report on how they used them to troubleshoot a problem, and can present a counterargument to the current practice, I could reconsider.

G. Branden Robinson <gbranden>
Group administrator
Sat 14 Aug 2021 12:17:26 AM UTC, original submission:  


src/roff/nroff/tests/verbose_option_works.sh

  A '-T' option is needed for "nroff" to match the tested string by
"grep".

  Using a variable, for example "Toption=-Tascii",
 instead of a repeated constant string,
 makes changes easier and smaller.

Bjarni Ingi Gislason <bjarniig>

 

(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 gbranden (Posted a comment)
  • -email is unavailable- added by bjarniig (Submitted the item)
  •  

    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 14 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-08-23 gbranden StatusIn Progress Fixed
        Open/ClosedOpen Closed
        Planned ReleaseNone 1.23.0
    2021-08-23 gbranden Summary[nroff]: verbose_option_works.sh: confounded by GROFF_TYPESETTER in environment [nroff]: verbose_option_works.sh: confounded by environment variables
    2021-08-21 gbranden Severity1 - Wish 3 - Normal
        StatusRejected In Progress
        Open/ClosedClosed Open
        Summaryverbose_option_works.sh: option &quot;-T...&quot; for &quot;nroff&quot; is a variable, but a constant in the test string [nroff]: verbose_option_works.sh: confounded by GROFF_TYPESETTER in environment
    2021-08-16 gbranden CategoryNone Core
        Severity3 - Normal 1 - Wish
        Item GroupWarning/Suspicious behaviour Test
        StatusNone Rejected
        Assigned toNone gbranden
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code