Skip to content

Inconsistent behaviour between commands and preconditions #2057

@Mice7R

Description

@Mice7R

Alright another one that wasted me too much time: the way dagu handles variable expansion in commands -or other parts- differ from the preconditions.

I couldn’t find any mention of this difference in the documentation, and I’m not sure whether it’s intentional.

Example DAG

This is a simple example dag that creates a file dagu-test.txt in the users home and echo 1 if the created file exists.

env:
  TEST_FILE: ~/dagu-test.txt

steps:
  - command: touch $TEST_FILE
  - command: echo 1
    preconditions:
      - condition: test -f $TEST_FILE

Expected behaviour

The file dagu-test.txt is created in the users home and the second step echoes a 1.

Actual behaviour

The file is created but the second step is skipped with failed preconditon.

Reason

I've managed to track the issue to the way dagu is expanding the variable -or lack thereof- in the precondition.

The expansion of the variable is being handled differently in the precondition and the ~ is not being expanded. Instead the shell is looking for a literal ~. Replacing ~ with a path or variable works. eg TEST_FILE: $HOME/dagu-test.txt.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions