help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Preferred method wrapping mkdir


From: Greg Wooledge
Subject: Re: [Help-bash] Preferred method wrapping mkdir
Date: Fri, 20 Nov 2015 11:16:15 -0500
User-agent: Mutt/1.4.2.3i

> > mkdir() { command mkdir "$@" && cd "${@:(-1)}"; }
> > 
> > This allows you to do, for example, "mkdir -p /some/long/path" and
> > have it work as expected (ending with cd /some/long/path).
> 
> Why not just:
> mkdir(){ command mkdir "$1" && cd "$1"; }

Because then you can't do "mkdir -p /some/long/path".  Or possibly other
mkdir options that I can't think of off hand.

> or even better:
> mkdir()
> {
>     if [ -n "$2" -o -z "$1" ]; then

I think you mean  if (($# != 1))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]