Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXIT_CODE is empty when ignore_error:true #1826

Open
officel opened this issue Sep 20, 2024 · 0 comments
Open

EXIT_CODE is empty when ignore_error:true #1826

officel opened this issue Sep 20, 2024 · 0 comments
Labels
state: needs triage Waiting to be triaged by a maintainer.

Comments

@officel
Copy link

officel commented Sep 20, 2024

  • Task version: Task version: v3.39.2 (h1:Zt7KXHmMNq5xWZ1ihphDb+n2zYLCo4BdRe09AnMMIgA=)
  • Operating system: Linux 5.15.153.1-microsoft-standard-WSL2 #1 SMP Fri Mar 29 23:14:13 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux # Windows 11 + WSL2 + Ubuntu 24.04 LTS
  • Experiments enabled:

In v3.39.2, EXIT_CODE seem to be empty if ignore_error: true.
I would like the error message to be suppressed or EXIT_CODE to be passed.

somedir/Taskfile.yml

version: '3'
includes:
  base:
    taskfile: ~/Taskfile.yml
    flatten: true

tasks:
  description:
    desc: task description.
    aliases:
      - desc
    silent: true
    cmds:
      - date -I sec

I have multiple repository directories.
I want to share the default task in a global Taskfile.

~/Taskfile.yml

version: '3'

tasks:
  default:
    summary: |
      default task is list tasks.
    cmds:
      # - defer: echo "exit code is {{.EXIT_CODE}}"
      - defer: '{{if .EXIT_CODE}} task --list-all --sort alphanumeric{{end}}'
      - cmd: task --list --sort alphanumeric
        # ignore_error: true
    dir: "{{.USER_WORKING_DIR}}"
    silent: true
    aliases:
      - ls
<ommit>

In some directory, there is a task with desc, so the execution result of task is --list.

In the home directory and in directories that use the global ~/Taskfile.yml, there are no tasks with desc, so the execution result of task should be --list-all.

in some dir

$ task
task: Available tasks for this project:
* description:       task description.      (aliases: desc)

in home dir

$ task
task: No tasks with description available. Try --list-all to list all tasks
task: Available tasks for this project:
* default:                            (aliases: ls)
* list-all:                           (aliases: la)
* test:special-variables:             (aliases: test:sv)
task: Failed to run task "default": exit status 1

in home dir and ignore_error: true. so .EXIT_CODE is empty

$ task
task: No tasks with description available. Try --list-all to list all tasks

any ideas?

@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: needs triage Waiting to be triaged by a maintainer.
Projects
None yet
Development

No branches or pull requests

2 participants