DannyBen / bashly

Bash command line framework and CLI generator
https://bashly.dannyb.co
MIT License
2.09k stars 87 forks source link

eval in .zshrc triggers initialise.sh unexpectedly – Is this intended behavior? #558

Closed Linbreux closed 1 month ago

Linbreux commented 1 month ago

Hi,

I'm encountering an issue with a script I added to my initialise.sh file. The purpose of the script is to perform some checks and print a message, it includes a guard so that it only runs once after a reboot, and only when my Bashly program is executed for the first time.

However, due to the following line in my .zshrc file:

eval "$(<script> completions)"

I'm seeing the following error when starting a new shell:

(eval):2: bad pattern: ^[[34m╔════════════════════════════════════════╗^[[0m

It seems like the completions are causing the initialise.sh script to run earlier than expected.

My question is:

Any advice or suggestions would be greatly appreciated!

Thanks in advance!

DannyBen commented 1 month ago

I am not sure I completely understand the issue.

When you say you have this in your .zshrc:

eval "$(<script> completions)"

you mean, <script> is the bashly generated script?

If so - of course it will call the initialize function. The initialize function is always called, whenever you run the script, and it is the first thing getting called - look at your generated script, at the bottom.

Your initialize function should include only simple things that are needed by all (or most) of the other functions in your script. In fact, I would even say further that in most cases, you should avoid using it - I rarely use it myself.

Based on the information given - the only advice I can offer is to move whatever you have placed in initialize to a different place. If you share its contents or purpose, I may be able to help further.

Linbreux commented 1 month ago

Hi @DannyBen

you mean, Githubissues.

  • Githubissues is a development platform for aggregating issues.