You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Giovanni Bajo <ra...@develer.com> on 2006/01/07 15:54:10 UTC

[PATCH, svnmerge] Try "stty -a" to find out console width

Hello,

svnmerge automatically formats and word-wraps its help screens to the user
console width (if it manages to extract it). It has several methods (for
different operating systems), and this patch adds another fallback: it tries
calling "stty -a" and parsing its output with a simple regular expression.
This should work well on some UNIX flavours (including Linux).

Committed as r18008.

[[[
When trying to get the width of the console, also try parsing the output
of "stty -a" which usually contains this information.

* contrib/client-side/svnmerge.py:
  (console_width): Try parsing 'stty -a' output.
]]]
-- 
Giovanni Bajo

Re: [PATCH, svnmerge] Try "stty -a" to find out console width

Posted by Kalle Olavi Niemitalo <ko...@iki.fi>.
Giovanni Bajo <ra...@develer.com> writes:

> svnmerge already sets LC_MESSAGES=C to be able to consistently parse the output
> of svn's command line client. I reckon this should also fix these issues with
> translation, right?

Ah, that's right... unless someone has defined LC_ALL, which
overrides LC_MESSAGES.

> BTW, what about "stty -g"? Is its output portable?

It is only supposed to be parseable by the same stty program on
the same computer (though perhaps a different terminal device).

Re: [PATCH, svnmerge] Try "stty -a" to find out console width

Posted by Carsten Koch <Ca...@icem.com>.
Giovanni Bajo wrote:
...
> Ah nice to know! But I'd rather stay with a more portable form (for some
> meaning of "portable"). BTW, what about "stty -g"? Is its output portable?

No.


Same tty on...

...IRIX 6.5:
d26:1805:cbe:b3b:9600:9600:3:1c:8:15:4:0:0:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:1

...SunOS 5.8:
2506:5:bf:8a3b:3:1c:8:15:4:0:0:0:11:13:1a:19:12:f:17:16:0:0:1:1:0:00:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0

...HP-UX 11:
d02:1805:972:3b:0:3:1c:8:15:4:0:ff:ff:d02:1805:972:3b:3:1c:8:15:4:0:ff:ff:ff:ff:ff:1:1:1a:11:13:0:0:1a:ff:0:44:eb:0

...AIX 5.3:
3:1c:8:15:4:0:0:11:13:1a:19:12:f:17:16:0:10306:c05:f04bf:2a003b:


Carsten.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH, svnmerge] Try "stty -a" to find out console width

Posted by Giovanni Bajo <ra...@develer.com>.
Kalle wrote:

> As GNU coreutils 5.93 documents that stty -a prints "all current
> settings in human-readable form", I wonder whether some
> implementation could make the word "columns" depend on the
> locale.  The specification of "stty" in IEEE Std 1003.1, 2004
> Edition does not say anything about setting or retrieving the
> size of the console, but it requires at least the "speed",
> "ispeed", and "ospeed" words in "stty -a" output to be unaffected
> by locale; perhaps this is why GNU coreutils 5.93 leaves
> "columns" untranslated.

svnmerge already sets LC_MESSAGES=C to be able to consistently parse the output
of svn's command line client. I reckon this should also fix these issues with
translation, right?

> GNU coreutils also supports "stty size", which outputs only
> the rows and columns and may thus be more reliable to parse.
> However, I don't know how widely that's supported elsewhere.

Ah nice to know! But I'd rather stay with a more portable form (for some
meaning of "portable"). BTW, what about "stty -g"? Is its output portable?

Giovanni Bajo


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH, svnmerge] Try "stty -a" to find out console width

Posted by Alan Barrett <ap...@cequrux.com>.
On Sat, 07 Jan 2006, Kalle Olavi Niemitalo wrote:
> As GNU coreutils 5.93 documents that stty -a prints "all current
> settings in human-readable form", I wonder whether some
> implementation could make the word "columns" depend on the
> locale.

Setting LANG=C (or similar tricks with LC_*) should bypass such
translation.

--apb (Alan Barrett)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH, svnmerge] Try "stty -a" to find out console width

Posted by Giovanni Bajo <ra...@develer.com>.
Carsten Koch <Ca...@icem.com> wrote:

>> GNU coreutils also supports "stty size", which outputs only
>> the rows and columns and may thus be more reliable to parse.
>> However, I don't know how widely that's supported elsewhere.
>
> IRIX 6.5 and SunOS 5.8 do not support it,
> HP-UX 11 and AIX 5.3 do.


Since you seem to have access to different UNIX systems, can you verify that
the output of, eg., "svnmerge.py help merge" is word-wrapped correctly on the
console width on all of the systems? It would default to 80 cols if it can't
find a way to get the terminal width.

Thanks,
Giovanni Bajo


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH, svnmerge] Try "stty -a" to find out console width

Posted by Carsten Koch <Ca...@icem.com>.
Kalle Olavi Niemitalo wrote:
...
> GNU coreutils also supports "stty size", which outputs only
> the rows and columns and may thus be more reliable to parse.
> However, I don't know how widely that's supported elsewhere.

IRIX 6.5 and SunOS 5.8 do not support it,
HP-UX 11 and AIX 5.3 do.

Carsten.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH, svnmerge] Try "stty -a" to find out console width

Posted by Kalle Olavi Niemitalo <ko...@iki.fi>.
Giovanni Bajo <ra...@develer.com> writes:

> svnmerge automatically formats and word-wraps its help screens to the user
> console width (if it manages to extract it). It has several methods (for
> different operating systems), and this patch adds another fallback: it tries
> calling "stty -a" and parsing its output with a simple regular expression.
> This should work well on some UNIX flavours (including Linux).

As GNU coreutils 5.93 documents that stty -a prints "all current
settings in human-readable form", I wonder whether some
implementation could make the word "columns" depend on the
locale.  The specification of "stty" in IEEE Std 1003.1, 2004
Edition does not say anything about setting or retrieving the
size of the console, but it requires at least the "speed",
"ispeed", and "ospeed" words in "stty -a" output to be unaffected
by locale; perhaps this is why GNU coreutils 5.93 leaves
"columns" untranslated.

GNU coreutils also supports "stty size", which outputs only
the rows and columns and may thus be more reliable to parse.
However, I don't know how widely that's supported elsewhere.