shellcheck icon indicating copy to clipboard operation
shellcheck copied to clipboard

Readonly reassignment

Open aeiplatform opened this issue 2 years ago • 1 comments

For new checks and feature suggestions

  • [x] https://www.shellcheck.net/ (i.e. the latest commit) currently gives no useful warnings about
  • [x] I searched through https://github.com/koalaman/shellcheck/issues and found related #1287

Here's a snippet or screenshot that shows the problem:

#!/bin/sh
readonly a=Hello
a="$a World"

Here's what shellcheck currently says:

Nothing.

Here's what I wanted or expected to see:

Line 3:
a="$a World"
^-- SCXXXX Variable "a" is set as read-only.

aeiplatform avatar May 23 '23 17:05 aeiplatform

another example

#!/usr/bin/env bash

declare -r textA='readonly'
declare textB='appended'

textA+=",${textB}"

PeterPitterling avatar Mar 06 '24 16:03 PeterPitterling