Skip to content

Commit aa9f4de

Browse files
committed
tune up the autoWidth impl and docco how it's impl
so people can determine if it is worth it. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/cli/trunk@779586 13f79535-47bb-0310-9956-ffa450edef68
1 parent 32c9109 commit aa9f4de

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

src/java/org/apache/commons/cli/HelpFormatter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public class HelpFormatter
140140
/**
141141
* Flag to determine if we try to determine terminal width
142142
*/
143-
public boolean autoWidth = false;
143+
private boolean autoWidth = false;
144144

145145
/**
146146
* Sets the 'width'.
@@ -702,7 +702,7 @@ private static String unixCmdOut(String program)
702702
String rstr;
703703
ByteArrayOutputStream sout = new ByteArrayOutputStream();
704704
try {
705-
Process p = Runtime.getRuntime().exec(new String[] {"sh","-c",program});
705+
Process p = Runtime.getRuntime().exec(new String[] {"/bin/sh","-c",program});
706706
in = p.getInputStream();
707707
while ((c = in.read()) != -1) {
708708
sout.write(c);

xdocs/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
<release version="1.3" date="in SVN">
2626
<action type="add" dev="jim" issue="CLI-166">
2727
HelpFormatter can now autodetect (if desired) terminal width under Unix.
28+
This is done via setAutoWidth(true) and the actual terminal width determination
29+
is done internally by calling "/bin/sh -c stty -a < /dev/null". If anything
30+
fails, the defaultWidth is used.
2831
</action>
2932
<action type="add" dev="ebourg" issue="CLI-160">
3033
PosixParser now supports partial long options (--ver instead of --version)

0 commit comments

Comments
 (0)