On 20 February 2017 at 09:18, T_POL <t_...@tiscali.it> wrote:
>
> not sure about that but I think the "cd" command executes indeed
> but it's valid only for the scripts' environment and not for the
> shell you started the script from.

*ding* *ding* *ding*  We have a winner!

Shells execute in their own instance of bash (or whatever) - a
subshell.  The way to do this is with an alias or function, depending
on your needs (aliases don't except parameters, functions do), so
here's the function for "mdcd":

$ mdcd() {
    # additional checks here, per original post
    mkdir $1
    cd $1
}


Alternatively, you can force a script to run in the current shell by sourcing it

$ . {scriptname}

Note the "." between the prompt and script (you can also use the more
literal "source"):

$ source {scriptname}

Another option, just for completeness, would be to alias sourcing a
script, e.g.:

$ alias mdcd='. {path to script}'

-- 
Andy

The only person to have all his work done by Friday was Robinson Crusoe
_______________________________________________
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org

Reply via email to