Re: [OT] bash help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 20 February 2017 at 09:18, T_POL <t_pol@xxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux