From: Petr Vorel <pvorel@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v7 2/4] ci: add patchwork communication script
Date: Tue, 15 Apr 2025 19:35:35 +0200 [thread overview]
Message-ID: <20250415173535.GA520691@pevik> (raw)
In-Reply-To: <20250415-patchwork_ci-v7-2-bc0b9adca971@suse.com>
Hi Andrea,
...
> +fetch_series() {
> + local current_time=$(date +%s)
> + local since_time=$(expr $current_time - $PATCHWORK_SINCE)
> + local date=$(date -u -d @$since_time +"%Y-%m-%dT%H:%M:%SZ")
> + local stdout=$(curl -k -G "$PATCHWORK_URL/api/events/" \
> + --data "category=series-completed" \
> + --data "project=ltp" \
> + --data "state=new" \
> + --data "since=$date" \
> + --data "archive=no")
> +
> + [ $? -eq 0 ] || exit 1
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.
Try:
$ cat foo.sh
#!/bin/sh
foo()
{
local foo=$(aasfd_command_which_fails)
[ $? -eq 0 ] || exit 1
echo "run after"
}
bar()
{
local foo
foo=$(aasfd_command_which_fails)
[ $? -eq 0 ] || exit 1
echo "will not run after"
}
foo
bar
---
$ bash ./foo.sh
./foo.sh: line 5: aasfd_command_which_fails: command not found
run after
./foo.sh: line 15: aasfd_command_which_fails: command not found
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.
(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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2025-04-15 17:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-15 16:39 [LTP] [PATCH v7 0/4] Support for Patchwork CI Andrea Cervesato
2025-04-15 16:39 ` [LTP] [PATCH v7 1/4] ci: install dependences for patchwork-ci script Andrea Cervesato
2025-04-15 16:39 ` [LTP] [PATCH v7 2/4] ci: add patchwork communication script Andrea Cervesato
2025-04-15 17:35 ` Petr Vorel [this message]
2025-04-15 20:42 ` Dennis Brendel via ltp
2025-04-16 12:48 ` Petr Vorel
2025-04-16 7:40 ` Andrea Cervesato via ltp
2025-04-16 7:49 ` Andrea Cervesato via ltp
2025-04-16 7:04 ` Li Wang via ltp
2025-04-16 8:23 ` Andrea Cervesato via ltp
2025-04-16 8:38 ` Petr Vorel
2025-04-16 8:55 ` Li Wang via ltp
2025-04-15 16:39 ` [LTP] [PATCH v7 3/4] ci: add ci-patchwork-trigger workflow Andrea Cervesato
2025-04-15 16:39 ` [LTP] [PATCH v7 4/4] ci: apply patchwork series in ci-docker-build workflow Andrea Cervesato
2025-04-15 16:53 ` [LTP] [PATCH v7 0/4] Support for Patchwork CI Andrea Cervesato via ltp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250415173535.GA520691@pevik \
--to=pvorel@suse.cz \
--cc=andrea.cervesato@suse.de \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.