bashsupport-pro icon indicating copy to clipboard operation
bashsupport-pro copied to clipboard

`Unresolved variable` inspection does not support `$''foo''` syntax

Open 5HT2 opened this issue 11 months ago • 2 comments

IDEA 2024.3.5 / BashSupport Pro 4.6.3.243
# I moved this into a new line because it made the example too wide to read on GitHub:
#'s/^([^\ ]*) ?(\(?[A-z_\.\-]*\)?)(([_\-\ ]*)(PowerShell[^\ ]*)?(.+)[_\-\ ]*Microsoft.+)(\.pdf)$/\1.pdf/g'
fNew=$''$(printf '%s' $''$pdf'' | gsed -E $''$fRgx'')''

# Check if filename is shorter than the original
# No reason to rename if it's just making the filename worse
if (( ${#fNew} < ${#pdf} )); then
    log 0 "# Rename: $pdf → ${fNew}"

    # Check if dest exists
    if [[ -f $''$fNew'' ]]; then
        log 1 "Failed to rename '${pdf}' → '${fNew}', destination exists" || return $?
    fi

    # Rename
    mv $''$pdf'' $''$fNew'' || {
        log 1 "Failed to rename '${pdf}' → '${fNew}'" || return $?
    }

    (( rNum += 1 ))
    filesNew+=($''$fNew'')
else
    (( sNum += 1 ))
    filesNew+=($''$pdf'')
fi

5HT2 avatar May 12 '25 03:05 5HT2

@5HT2 Thanks for reporting!

Similar to #200 , I couldn't find anything about $''...'' in the Zsh documentation. https://zsh.sourceforge.io/Doc/Release/Shell-Grammar.html#Shell-Grammar

I know about $'...', which suppports escaping in single quotes, but I haven't seen any use of double-single-quoted stings yet.

Is there any documentation you're aware of about this syntax? That would help to understand and support it. Thanks!

jansorg avatar May 12 '25 09:05 jansorg

@5HT2 I was distracted by the $''...'' syntax and didn't notice your reference to the error "$fNew is referenced but not assigned" error.

If I paste the snippet you provided into a .zsh file, then I don't see the error. Does the snippet work for you too if you paste into a new file?

It's possible that the context of the original file around the copied snippet is breaking the parsing. If possible, could you provide more lines before and after the snippet to help me reproduce?

jansorg avatar May 13 '25 15:05 jansorg