zsh-users
 help / color / mirror / code / Atom feed
* zdotdir
@ 2014-03-10 11:51 Yuri D'Elia
  2014-03-10 12:01 ` zdotdir Aaron Kaufman
  2014-03-10 15:32 ` zdotdir Bart Schaefer
  0 siblings, 2 replies; 10+ messages in thread
From: Yuri D'Elia @ 2014-03-10 11:51 UTC (permalink / raw)
  To: zsh-users

I recently decided to move all my config files (.zshrc, .zprofile, etc)
to ~/.zsh/, so in my ~/.zshenv I set:

ZDOTDIR=~/.zsh

However, I would like then the files not to have a leading dot, so I
could just have

~/.zsh/zprofile like in /etc/.

Is it possible?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: zdotdir
  2014-03-10 11:51 zdotdir Yuri D'Elia
@ 2014-03-10 12:01 ` Aaron Kaufman
  2014-03-10 13:03   ` zdotdir Yuri D'Elia
  2014-03-10 15:32 ` zdotdir Bart Schaefer
  1 sibling, 1 reply; 10+ messages in thread
From: Aaron Kaufman @ 2014-03-10 12:01 UTC (permalink / raw)
  To: Yuri D'Elia; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 467 bytes --]

You can use 'source' to source any file name.

For example: source $HOME/.zsh/zprofile and so on.
I hope that helps.
On Mar 10, 2014 4:55 AM, "Yuri D'Elia" <wavexx@thregr.org> wrote:

> I recently decided to move all my config files (.zshrc, .zprofile, etc)
> to ~/.zsh/, so in my ~/.zshenv I set:
>
> ZDOTDIR=~/.zsh
>
> However, I would like then the files not to have a leading dot, so I
> could just have
>
> ~/.zsh/zprofile like in /etc/.
>
> Is it possible?
>
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: zdotdir
  2014-03-10 12:01 ` zdotdir Aaron Kaufman
@ 2014-03-10 13:03   ` Yuri D'Elia
  0 siblings, 0 replies; 10+ messages in thread
From: Yuri D'Elia @ 2014-03-10 13:03 UTC (permalink / raw)
  To: zsh-users

On 03/10/2014 01:01 PM, Aaron Kaufman wrote:
> You can use 'source' to source any file name.
> 
> For example: source $HOME/.zsh/zprofile and so on.
> I hope that helps.

The only hook I have I zshenv, I cannot source the other files and get
the same effect from there.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: zdotdir
  2014-03-10 11:51 zdotdir Yuri D'Elia
  2014-03-10 12:01 ` zdotdir Aaron Kaufman
@ 2014-03-10 15:32 ` Bart Schaefer
  2014-03-10 17:28   ` zdotdir Yuri D'Elia
  1 sibling, 1 reply; 10+ messages in thread
From: Bart Schaefer @ 2014-03-10 15:32 UTC (permalink / raw)
  To: zsh-users

On Mar 10, 12:51pm, Yuri D'Elia wrote:
}
} However, I would like then the files not to have a leading dot, so I
} could just have
} 
} ~/.zsh/zprofile like in /etc/.
} 
} Is it possible?

Just create symbolic links:

cd $ZDOTDIR
for dotfile in zshenv zshrc zprofile zlogin; ln -s $dotfile .$dotfile

If for some reason you don't want to use symlinks, you can instead do

cd $ZDOTDIR
for dotfile in zshenv zshrc zprofile zlogin
  print "source \$ZDOTDIR/$dotfile" > .$dotfile

but that will print errors about missing files if you don't create all
four of the dot-less ones, which the symlink approach will not.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: zdotdir
  2014-03-10 15:32 ` zdotdir Bart Schaefer
@ 2014-03-10 17:28   ` Yuri D'Elia
  2014-03-10 18:25     ` return up two levels? Ray Andrews
  0 siblings, 1 reply; 10+ messages in thread
From: Yuri D'Elia @ 2014-03-10 17:28 UTC (permalink / raw)
  To: zsh-users

On 03/10/2014 04:32 PM, Bart Schaefer wrote:
> Just create symbolic links:
> 
> cd $ZDOTDIR
> for dotfile in zshenv zshrc zprofile zlogin; ln -s $dotfile .$dotfile
> 
> If for some reason you don't want to use symlinks, you can instead do
> 
> cd $ZDOTDIR
> for dotfile in zshenv zshrc zprofile zlogin
>   print "source \$ZDOTDIR/$dotfile" > .$dotfile
> 
> but that will print errors about missing files if you don't create all
> four of the dot-less ones, which the symlink approach will not.

Not fancy, but will do ;)
Thanks, didn't think about this.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* return up two levels?
  2014-03-10 17:28   ` zdotdir Yuri D'Elia
@ 2014-03-10 18:25     ` Ray Andrews
  2014-03-10 19:42       ` Peter Stephenson
  0 siblings, 1 reply; 10+ messages in thread
From: Ray Andrews @ 2014-03-10 18:25 UTC (permalink / raw)
  To: zsh-users

Didn't I read somewhere that one can return from a function 'up two 
levels'? i.e. that if function1 calls function2, that function2 can 
return both itself and function1? I have a helper function that might 
want to return to the calling function, or might want to return right 
back  to the shell. Of course I can do this with with return value tests 
within the calling function, but it would be nice if the helper function 
could handle it internally. Is it possible? 'exit' kills the shell 
itself, so it's too aggressive.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: return up two levels?
  2014-03-10 18:25     ` return up two levels? Ray Andrews
@ 2014-03-10 19:42       ` Peter Stephenson
  2014-03-11  3:00         ` Ray Andrews
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Stephenson @ 2014-03-10 19:42 UTC (permalink / raw)
  To: zsh-users

On Mon, 10 Mar 2014 11:25:23 -0700
Ray Andrews <rayandrews@eastlink.ca> wrote:

> Didn't I read somewhere that one can return from a function 'up two 
> levels'? i.e. that if function1 calls function2, that function2 can 
> return both itself and function1?

function1() { function2; print Doesn\'t get called; }
function2() { trap 'return' EXIT; print Does get called; }


% function1
Does get called


Of course you can return at the point you set the trap, I'm just
illustrating that the forced return of the parent function isn't tied to
the child function returning immediately.

And regardless of options EXIT traps are only associated with the
immediate parent, so...


function0() { function1; print Does get called, too; }


% function0
Does get called
Does get called, too


So forcing a whole hierarchy to return immediately is harder work.  You can set an exit trap inside an exit trap, if you want (I haven't tried but I have a vague memory of debugging this years ago), but it gets messy.

pws


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: return up two levels?
  2014-03-10 19:42       ` Peter Stephenson
@ 2014-03-11  3:00         ` Ray Andrews
  2014-03-11  3:33           ` Kurtis Rader
  0 siblings, 1 reply; 10+ messages in thread
From: Ray Andrews @ 2014-03-11  3:00 UTC (permalink / raw)
  To: zsh-users

On 03/10/2014 12:42 PM, Peter Stephenson wrote:

Peter:
> function1() { function2; print Doesn\'t get called; }
> function2() { trap 'return' EXIT; print Does get called; }
Thanks, that about does it. I've not used traps up till now.

BTW I'm enjoying  your book. Hats off to Oliver as well of course.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: return up two levels?
  2014-03-11  3:00         ` Ray Andrews
@ 2014-03-11  3:33           ` Kurtis Rader
  2014-03-11 14:54             ` Ray Andrews
  0 siblings, 1 reply; 10+ messages in thread
From: Kurtis Rader @ 2014-03-11  3:33 UTC (permalink / raw)
  To: Ray Andrews; +Cc: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 1078 bytes --]

Please don't use that technique unless it's in the context of something
atypical like a debugger. It's a really bad software pattern. It's spooky
action at a distance. It's a form of monkey-patching. it practically
guarantees hard to debug errors. Plus a large number of other problems.
Don't do it. Be explicit about return values. If you want a caller of
function2 to exit immediately have function2 return non-zero and test for
that. For example,

function2() { print I failed to do my job; return 1 }
function1() { if ! function2; then; print unexpected failure; return 0; fi;
print life is good }



On Mon, Mar 10, 2014 at 8:00 PM, Ray Andrews <rayandrews@eastlink.ca> wrote:

> On 03/10/2014 12:42 PM, Peter Stephenson wrote:
>
> Peter:
>
>> function1() { function2; print Doesn\'t get called; }
>> function2() { trap 'return' EXIT; print Does get called; }
>>
> Thanks, that about does it. I've not used traps up till now.
>
> BTW I'm enjoying  your book. Hats off to Oliver as well of course.
>
>


-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: return up two levels?
  2014-03-11  3:33           ` Kurtis Rader
@ 2014-03-11 14:54             ` Ray Andrews
  0 siblings, 0 replies; 10+ messages in thread
From: Ray Andrews @ 2014-03-11 14:54 UTC (permalink / raw)
  To: zsh-users

On 03/10/2014 08:33 PM, Kurtis Rader wrote:
> Please don't use that technique unless it's in the context of something
> atypical like a debugger. It's a really bad software pattern. It's spooky
> action at a distance. It's a form of monkey-patching. it practically
> guarantees hard to debug errors. Plus a large number of other problems.
> Don't do it. Be explicit about return values. If you want a caller of
> function2 to exit immediately have function2 return non-zero and test for
> that. For example,
>
> function2() { print I failed to do my job; return 1 }
> function1() { if ! function2; then; print unexpected failure; return 0; fi;
> print life is good }
>
Hmmm, sobering advice. I'm always looking to expand the techniques 
available to me,
and Peter's 'trap' idea does/would streamline my code for this one 
particular problem,
which is just a very short helper function called in almost all of my 
other functions  in
a trivial and routine sort of way where there are unlikely to be any 
strange issues. Still, this
trap thing violates the rule of least surprise and breaks the basic 
rules of code flow, so
I do take your point.  I guess if this sort of thing can be considered 
'standard zsh practice'
then I'm inclined to keep it, but if not, then out it goes.  But all the 
'sh's' have so many
abominable and dirty practices anyway that this trap would hardly stand 
out ;-)


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-03-11 14:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-10 11:51 zdotdir Yuri D'Elia
2014-03-10 12:01 ` zdotdir Aaron Kaufman
2014-03-10 13:03   ` zdotdir Yuri D'Elia
2014-03-10 15:32 ` zdotdir Bart Schaefer
2014-03-10 17:28   ` zdotdir Yuri D'Elia
2014-03-10 18:25     ` return up two levels? Ray Andrews
2014-03-10 19:42       ` Peter Stephenson
2014-03-11  3:00         ` Ray Andrews
2014-03-11  3:33           ` Kurtis Rader
2014-03-11 14:54             ` Ray Andrews

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).