Package org.jnode.shell

Examples of org.jnode.shell.ShellFailureException


    private boolean exported;
    private boolean readOnly;

    VariableSlot(String name, String value, boolean exported) {
        if (name == null) {
            throw new ShellFailureException("null name");
        }
        if (value == null) {
            throw new ShellFailureException("null value");
        }
        this.value = value;
        this.exported = exported;
        this.name = name;
    }
View Full Code Here


                CommandIO[] ios = new CommandIO[holders.length];
                for (int i = 0; i < ios.length; i++) {
                    ios[i] = holders[i].getIO();
                }
                if ((getFlags() & BjorneInterpreter.FLAG_ASYNC) != 0) {
                    throw new ShellFailureException(
                            "asynchronous execution (&) not implemented yet");
                } else {
                    rc = childContext.execute(command, ios);
                }
            }
View Full Code Here

            case PERCENT:
                return patternEdit(value.toString(), word, true, false);
            case DPERCENT:
                return patternEdit(value.toString(), word, true, true);
            default:
                throw new ShellFailureException("unimplemented substitution operator (" + operator + ")");
        }
    }
View Full Code Here

        return interpreter.resolveInputStream(stream);
    }

    CommandIO getIO(int index) {
        if (index < 0) {
            throw new ShellFailureException("negative stream index");
        } else if (index < holders.length) {
            return holders[index].getIO();
        } else {
            return null;
        }
View Full Code Here

        }
    }
   
    void setIO(int index, CommandIO io, boolean mine) {
        if (index < 0 || index >= holders.length) {
            throw new ShellFailureException("bad stream index");
        } else {
            holders[index].setIO(io, mine);
        }
    }
View Full Code Here

        }
    }
   
    void setIO(int index, CommandIOHolder holder) {
        if (index < 0 || index >= holders.length) {
            throw new ShellFailureException("bad stream index");
        } else {
            holders[index].setIO(holder);
        }
    }
View Full Code Here

        if (assignments != null) {
            for (int i = 0; i < assignments.length; i++) {
                String assignment = assignments[i].getText();
                int pos = assignment.indexOf('=');
                if (pos <= 0) {
                    throw new ShellFailureException("misplaced '=' in assignment");
                }
                String name = assignment.substring(0, pos);
                String value = dollarBacktickExpand(assignment.substring(pos + 1)).toString();
                this.setVariable(name, dequote(value).toString());
            }
View Full Code Here

                    }
                } else {
                    try {
                        fd = Integer.parseInt(io.getText());
                    } catch (NumberFormatException ex) {
                        throw new ShellFailureException("Invalid &fd number");
                    }
                }
                // If necessary, grow the fd table.
                if (fd >= holders.length) {
                    CommandIOHolder[] tmp = new CommandIOHolder[fd + 1];
                    System.arraycopy(holders, 0, tmp, 0, fd + 1);
                    holders = tmp;
                }

                CommandIOHolder stream;
                CommandInput in;
                CommandOutput out;
                switch (redir.getRedirectionType()) {
                    case REDIR_DLESS:
                    case REDIR_DLESSDASH:
                        String here = redir.getHereDocument();
                        if (redir.isHereDocumentExpandable()) {
                            here = dollarBacktickExpand(here).toString();
                        }
                        in = new CommandInput(new StringReader(here));
                        stream = new CommandIOHolder(in, true);
                        break;

                    case REDIR_GREAT:
                        try {
                            File file = new File(redir.getArg().getText());
                            if (isNoClobber() && file.exists()) {
                                throw new ShellException("File already exists");
                            }
                            out = new CommandOutput(new FileOutputStream(file));
                            stream = new CommandIOHolder(out, true);
                        } catch (IOException ex) {
                            throw new ShellException("Cannot open output file", ex);
                        }
                        break;

                    case REDIR_CLOBBER:
                    case REDIR_DGREAT:
                        try {
                            FileOutputStream tmp = new FileOutputStream(redir.getArg().getText(),
                                    redir.getRedirectionType() == REDIR_DGREAT);
                            stream = new CommandIOHolder(new CommandOutput(tmp), true);
                        } catch (IOException ex) {
                            throw new ShellException("Cannot open output file", ex);
                        }
                        break;

                    case REDIR_LESS:
                        try {
                            File file = new File(redir.getArg().getText());
                            in = new CommandInput(new FileInputStream(file));
                            stream = new CommandIOHolder(in, true);
                        } catch (IOException ex) {
                            throw new ShellException("Cannot open input file", ex);
                        }
                        break;

                    case REDIR_LESSAND:
                        try {
                            int fromFd = Integer.parseInt(redir.getArg().getText());
                            stream = (fromFd >= holders.length) ? null :
                                    new CommandIOHolder(holders[fromFd]);
                        } catch (NumberFormatException ex) {
                            throw new ShellException("Invalid fd after <&");
                        }
                        break;

                    case REDIR_GREATAND:
                        try {
                            int fromFd = Integer.parseInt(redir.getArg().getText());
                            stream = (fromFd >= holders.length) ? null :
                                    new CommandIOHolder(holders[fromFd]);
                        } catch (NumberFormatException ex) {
                            throw new ShellException("Invalid fd after >&");
                        }
                        break;

                    case REDIR_LESSGREAT:
                        throw new UnsupportedOperationException("<>");
                    default:
                        throw new ShellFailureException("unknown redirection type");
                }
                holders[fd] = stream;
            }
            ok = true;
        } finally {
View Full Code Here

        return list.toArray(new BjorneToken[list.size()]);
    }
       
    private void substituteAliases(List<BjorneToken> list, int pos, int depth) throws ShellSyntaxException {
        if (depth > 10) {
            throw new ShellFailureException("probable cycle detected in alias expansion");
        }
        String aliasName = list.get(pos).getText();
        String alias = aliases.get(aliasName);
        if (alias == null) {
            return;
View Full Code Here

                            "'continue' has been executed in an inappropriate context");
                case BjorneInterpreter.BRANCH_RETURN:
                    throw new ShellSyntaxException(
                            "'return' has been executed in an inappropriate context");
                default:
                    throw new ShellFailureException(
                            "unknown 'control' in BjorneControlException");
            }
        } catch (VmExit ex) {
            return ex.getStatus();
        } finally {
View Full Code Here

TOP

Related Classes of org.jnode.shell.ShellFailureException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.