added --nointeractive flag to gosh. FELIX-2661
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1022581 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Shell.java b/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Shell.java
index 8bd4eaf..f6a9518 100644
--- a/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Shell.java
+++ b/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Shell.java
@@ -61,6 +61,7 @@
" args are available as session variables $1..$9 and $args.",
"Usage: gosh [OPTIONS] [script-file [args..]]",
" -c --command pass all remaining args to sub-shell",
+ " -i --nointeractive don't start interactive session",
" --login login shell (same session, reads etc/gosh_profile)",
" -s --noshutdown don't shutdown framework when script completes",
" -x --xtrace echo commands before execution",
@@ -71,6 +72,7 @@
List<String> args = opt.args();
boolean login = opt.isSet("login");
+ boolean interactive = !opt.isSet("nointeractive");
if (opt.isSet("help"))
{
@@ -95,7 +97,7 @@
newSession.put("echo", true);
}
- if (login)
+ if (login && interactive)
{
URI uri = baseURI.resolve("etc/gosh_profile");
if (!new File(uri).exists())
@@ -117,11 +119,14 @@
}
}
- Object result;
+ Object result = null;
if (args.isEmpty())
{
- result = console(newSession);
+ if (interactive)
+ {
+ result = console(newSession);
+ }
}
else
{
@@ -159,7 +164,7 @@
result = newSession.execute(program);
}
- if (login && !opt.isSet("noshutdown"))
+ if (login && interactive && !opt.isSet("noshutdown"))
{
System.out.println("gosh: stopping framework");
shutdown();