Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit ad6a67b

Browse files
committed
fix for redirection in shell escape command
Fixes #476
1 parent eb5bdba commit ad6a67b

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

app/plugins/ui/commands/shell.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ const doShell = (argv, options, execOptions) => new Promise((resolve, reject) =>
4444
args[0] = process.env.OLDPWD
4545
}
4646

47-
if (!args.find(arg => arg.charAt(0) === '-') && cmd !== 'ls') {
47+
// see if we should use the built-in shelljs support
48+
if (!args.find(arg => arg.charAt(0) === '-') // any options? then no
49+
&& !args.find(arg => arg === '>') // redirection? then no
50+
&& cmd !== 'ls') {
4851
// shelljs doesn't like dash args
4952
// otherwise, shelljs has a built-in handler for this
5053

tests/tests/passes/02/shell.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2018 IBM Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
const common = require('../../../lib/common'),
18+
openwhisk = require('../../../lib/openwhisk'),
19+
ui = require('../../../lib/ui'),
20+
assert = require('assert'),
21+
keys = ui.keys,
22+
cli = ui.cli,
23+
sidecar = ui.sidecar
24+
25+
describe('shell commands', function() {
26+
before(common.before(this))
27+
after(common.after(this))
28+
29+
it('should have an active repl', () => cli.waitForRepl(this.app))
30+
31+
it('should echo hi', () => cli.do(`! echo hi`, this.app)
32+
.then(cli.expectOKWithCustom({ expect: 'hi' }))
33+
.catch(common.oops(this)))
34+
35+
it('should echo ho to a file', () => cli.do(`! echo ho > /tmp/testTmp`, this.app)
36+
.then(cli.expectOK)
37+
.catch(common.oops(this)))
38+
39+
it('should cat that file', () => cli.do(`! cat /tmp/testTmp`, this.app)
40+
.then(cli.expectOKWithCustom({ expect: 'ho' }))
41+
.catch(common.oops(this)))
42+
43+
it('should cat that file', () => cli.do(`! cd data`, this.app)
44+
.then(cli.expectOK)
45+
.catch(common.oops(this)))
46+
47+
it('should list commandFile.wsk', () => cli.do(`lls`, this.app)
48+
.then(cli.expectOKWithCustom({ expect: 'commandFile.wsk' }))
49+
.catch(common.oops(this)))
50+
})

0 commit comments

Comments
 (0)