
/*
 *  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
*/
package oracle.sample;

import org.unix4j.command.AbstractCommand;
import org.unix4j.context.ExecutionContext;
import org.unix4j.processor.LineProcessor;

/**
 * <p>
 * </p>
 *
 * @author velsubra
 */
public class PwdLineOperation extends AbstractCommand {

    public PwdLineOperation() {
        super("pwd", null);
    }

    public String getPwd() {
        return pwd;
    }

    private String pwd = null;


    @Override
    public LineProcessor execute(ExecutionContext context, LineProcessor output) {
        try {
            pwd = context.getCurrentDirectory().getCanonicalPath();
        } catch (Exception e) {
            pwd = context.getCurrentDirectory().getAbsolutePath();
        }
        return output;
    }
}
