QuarticCat / zsh-smartcache

A Zsh plugin to cache command output to boost shell startup.
MIT License
27 stars 2 forks source link

Bug: Complex script is dropped partially #1

Closed lentil32 closed 3 months ago

lentil32 commented 7 months ago

Steps to reproduce:

hello.zsh:

#!/bin/zsh
function edd () {
    echo "\
    # Hook to add new entries to the database.
    function __zoxide_hook() {
        # shellcheck disable=SC2312
        \command zoxide add -- "$(__zoxide_pwd)"
    }
    "
}

In terminal, run:

source hello.zsh; smartcache eval hello

Then, cache file is like: [md5]

    # Hook to add new entries to the database.
    function __zoxide_hook() {
        # shellcheck disable=SC2312

Expected cache file

[md5]

    # Hook to add new entries to the database.
    function __zoxide_hook() {
        # shellcheck disable=SC2312
         \command zoxide add -- "$(__zoxide_pwd)"
    }
QuarticCat commented 3 months ago

Hi, sorry for replying so late. I can't see problems in your example since directly invoking hello (assuming you mistyped hello as edd) gives me the incomplete output. However, I still addressed some bugs and pushed a new commit to fix them. Give me another example if the latest commit cannot solve your problem.