[LTP] [PATCH v7 2/4] ci: add patchwork communication script

Dennis Brendel dbrendel@redhat.com
Tue Apr 15 22:42:17 CEST 2025


On 4/15/25 7:35 PM, Petr Vorel wrote:
> Hi Andrea,
> You may have noticed in tst_test.sh, that local variable never uses $(...).
> It assign single value, but never call $(...). This is for a reason.
> [...]
> What happen? $? is assigned from result of local keyword,
> it overwrite previous result from $(...). Note even '#!/bin/sh -e'
> would not cause it to fail early.

Here is the corresponding documentation:
https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#index-local

> The return status is zero unless local is used outside a function, an
invalid name is supplied, or name is a readonly variable

So:
If you are interested in return statuses then don't *mask them* with local.

Use this pattern instead:

local my_var
my_var=$(my_expr)

Kind regards,
Dennis

> (Deliberately test with bash to demonstrate local behaves oddly not even in dash
> or 'busybox sh' but even with bash. And yes, given how many errors we caught
> with this script and generate_arch.sh and generate_syscalls.sh due shell strange
> syntax and behavior makes me wonder if we really want to use shell scripts for
> anything longer than 5 lines.)
> 
> Kind regards,
> Petr
> 



More information about the ltp mailing list