nash icon indicating copy to clipboard operation
nash copied to clipboard

interpreter: handling multiple init files

Open katcipis opened this issue 7 years ago • 2 comments

Today when there is multiple files that matches with possible init files (eg. init and init.sh) we just silently load the first one (which one is it ? I don't know =D). It would be nice to discuss this and get a better behavior.

katcipis avatar Jan 05 '18 04:01 katcipis

Hmmm and if we have the both file? Load both? Emacs, for instance, have this feature but I think it's pretty horrible. There are two init files:

  1. ~/.emacsrc
  2. ~/.emacs.d/init.el

However if (1) exists, (2) is not loaded. This can be tricky to understand in the first use of emacs (I need to debug this shit in past and was when I learnt that). I prefer just one case that be right, as $NASHPATH/init.<extension>, our current default.

Do you think that multiple init files can be useful in some way? I just can think being to add some mess to the conf stuff.

ryukinix avatar Mar 11 '18 21:03 ryukinix

Currently, the init file is $NASHPATH/init but it mimics the behavior of the import keyword: if the file without extension does not exists it looks for one with ".sh" extension.

init: https://github.com/NeowayLabs/nash/blob/master/cmd/nash/cli.go#L75-L88 import keyword: https://github.com/NeowayLabs/nash/blob/master/internal/sh/shell.go#L977-L989

Instead of two codes to handle this, we can the cli just execute import $NASHPATH+"/init".

i4ki avatar Mar 12 '18 17:03 i4ki