Skip to content

Add warning if run command has multiple arguments#187

Open
gportay wants to merge 2 commits intosavoirfairelinux:masterfrom
gportay:add-warning-if-run-command-has-multiple-arguments
Open

Add warning if run command has multiple arguments#187
gportay wants to merge 2 commits intosavoirfairelinux:masterfrom
gportay:add-warning-if-run-command-has-multiple-arguments

Conversation

@gportay
Copy link
Copy Markdown
Contributor

@gportay gportay commented Mar 25, 2025

Dear Maintainers,

I think the command run command_string is ambiguous, and cqfd should tell the user to switch to cqfd exec PROGRAM [ARGUMENTS...] if the command_string is a single command or to cqfd shell -c "command_string" if the command_string is a list of command.

More information in 344969c.

What do you think about this?

Comment thread cqfd Outdated
Comment thread cqfd Outdated
Comment thread cqfd
# Run alternate command
has_alternate_command=true

# Display a warning message if using run with multiple arguments
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this warning depends on if we really want to make cqfd run disappear totally or keep it for retrocompatibility

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes kind of. but there is a world before removing the command run and just deprecating it using a warning telling to switch to another command.

So up to you.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but the question is: do we really want to make people forget the "run" keyword ? If we don’t want that, then it is not necessary to put a warning.

run is used everywhere so it will be cumbersome for people to change, especially since there is no real issue with it at the moment, it works sufficiently well for what we need.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The run command does not work properly since cqfd run "touch foo" and cqfd run touch foo expect the same result. Since the command cannot forward the parameters property to the container, I suggest to move to another command that does it correctly.

This would prevent people to file an issue because it cannot deal with parameters:

cqfd run bash -c 'echo $0 $# $*' zero one two three
# no output because it runs bash -c echo $0 $# $* zero two three. the command string is word split.
#  sh -c [-abCefhimnuvx] [-o option]... [+abCefhimnuvx] [+o option]... command_string [command_name [argument...]]
# with command_string is echo instead of echo "$0 $# $*"
# arguments are: $0, $#, $*, zero, one, two, three instead of zero, one, two, three

The example below shows how the run command it broken.

So my opinion is to tell the user the command is broken and it should move to another one, as it does not work for every use case.

And we cannot fix it because the people using it as cqfd run "touch foo" would file an issue because it does not work anymore, and that example was part of the README.md.

So deprecating it is the only solution.

@florentsfl
Copy link
Copy Markdown
Contributor

My point of view is that we can make cqfd run behave like cqfd exec without explicitly asking people to change their habits

@gportay
Copy link
Copy Markdown
Contributor Author

gportay commented Apr 1, 2025

My point of view is that we can make cqfd run behave like cqfd exec without explicitly asking people to change their habits

As said... "And we cannot fix it because the people using it as cqfd run "touch foo" would file an issue because it does not work anymore, and that example was part of the README.md."

We can leave this alone, if you wish and leave this it its own state. It is broken for years now.

EDIT; The sudoization of cqfd is a good way of deprecating the commands, since it simplifies the CLI by removing a word in their command. cqfd run ... -> cqfd .... And we can still make some a glue for the transition by shifting it, but this is not truly correct if run exists in the container.

@florentsfl
Copy link
Copy Markdown
Contributor

With sudoization, what would cqfd "touch foo" do ?

@gportay
Copy link
Copy Markdown
Contributor Author

gportay commented Apr 1, 2025

With sudoization, what would cqfd "touch foo" do ?

It will fail because there is no "touch foo" binary.

The correct command would be cqfd sh -c "touch foo".

Currently it is cqfd shell -c "touch foo".

@florentsfl
Copy link
Copy Markdown
Contributor

okay okay it is getting more and more clear in my mind, but I’m almost sure we will never get rid of cqfd run for backward compatibility.

For example when you reuse a very old project which has an old cqfdrc and old pipeline jobs, it is always comfortable if it still runs.

But I’m ok to display warning for the cqfd run "touch foo" even if it will never be deprecated

And I would combine that with a sudoization not breaking backward compatibility, i.e. we keep run but we ditch exec and shell.

@gportay
Copy link
Copy Markdown
Contributor Author

gportay commented May 28, 2025

But I’m ok to display warning for the cqfd run "touch foo" even if it will never be deprecated

Yes.

Furthermore, it is just a warning that does not mention about possible deprecation.

@florentsfl florentsfl added this to the v5.8 milestone Jun 25, 2025
The command run is ambiguous.

This adds a warning if the command is run with multiple arguments
telling to use either exec or shell, depending if the arguments is
simple command or a list of commands.

See 344969c.
@gportay gportay force-pushed the add-warning-if-run-command-has-multiple-arguments branch from 14438d8 to a98bc7d Compare September 25, 2025 06:50
This adds a warning if the command with the concatenate option is run
with multiple arguments as the command run is ambigous and it does not
preserve the whitespaces.
@gportay gportay force-pushed the add-warning-if-run-command-has-multiple-arguments branch from a98bc7d to 83636d1 Compare September 25, 2025 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants