Fix posix functions
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1736008 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Posix.java b/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Posix.java
index 09cd5f1..f1d2581 100644
--- a/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Posix.java
+++ b/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Posix.java
@@ -105,7 +105,7 @@
this.processor = processor;
}
- protected void _main(CommandSession session, String[] argv) {
+ public void _main(CommandSession session, String[] argv) {
if (argv == null || argv.length < 1) {
throw new IllegalArgumentException();
}
@@ -265,7 +265,8 @@
System.out, System.err,
() -> session.get(".tmux"),
t -> session.put(".tmux", t),
- c -> startShell(session, c), argv);
+ c -> startShell(session, c),
+ Arrays.copyOfRange(argv, 1, argv.length));
}
private void startShell(CommandSession session, Terminal terminal) {
@@ -300,10 +301,15 @@
}
protected void nano(final CommandSession session, String[] argv) throws Exception {
- Commands.nano(Shell.getTerminal(session), System.out, System.err, session.currentDir(), argv);
+ Commands.nano(
+ Shell.getTerminal(session),
+ System.out,
+ System.err,
+ session.currentDir(),
+ Arrays.copyOfRange(argv, 1, argv.length));
}
- protected void watch(final CommandSession session, String[] argv) throws IOException, InterruptedException {
+ protected void watch(final CommandSession session, String[] argv) throws Exception {
final String[] usage = {
"watch - watches & refreshes the output of a command",
"Usage: watch [OPTIONS] COMMAND",
@@ -311,15 +317,12 @@
" -n --interval Interval between executions of the command in seconds",
" -a --append The output should be appended but not clear the console"
};
- final Options opt = Options.compile(usage).parse(argv);
- if (opt.isSet("help")) {
- opt.usage(System.err);
- return;
- }
+
+ Options opt = parseOptions(session, usage, argv);
+
List<String> args = opt.args();
if (args.isEmpty()) {
- System.err.println("Argument expected");
- return;
+ throw new IllegalArgumentException("Argument expected");
}
ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
final Terminal terminal = Shell.getTerminal(session);
@@ -364,7 +367,12 @@
}
protected void less(CommandSession session, String[] argv) throws IOException, InterruptedException {
- Commands.less(Shell.getTerminal(session), System.out, System.err, session.currentDir(), argv);
+ Commands.less(
+ Shell.getTerminal(session),
+ System.out,
+ System.err,
+ session.currentDir(),
+ Arrays.copyOfRange(argv, 1, argv.length));
}
protected void sort(CommandSession session, String[] argv) throws Exception {