bash command substitution return value being masked

tags: learning linux

content

  • for a line like local var=$(do_something), LSP throws this error:
Declare and assign separately to avoid masking return values.
  • it means, the return values from do_something will not be captured and will be lost
  • because the execution is:
    1. do_something is executed
    2. var is assigned
  • so if i run echo $? after local var=$(do_something), the result is always 0, because the return code of variable assignment is always 0

up

down

reference