process icon indicating copy to clipboard operation
process copied to clipboard

New feat req for echoing shell commands

Open ikappaki opened this issue 2 years ago • 3 comments

Hi,

it is considered a useful aid in shell scripting to echo the commands being executed.

This is a request to include such an :echo true option in shell or/and process (defaults to false).

e.g.

(babashka.process/shell {:echo true} "ls" "-al")
;; => /usr/bin/ls -al
...

This should work well with the babashka.process/*defaults* for echoing all commands in a block, e.g.

(binding [p/*defaults* (assoc p/*defaults* :echo true)]
  (p/shell "ls" "-al"))

would it be also possible to expose babashka.tasks/*defaults* in babashka please, it seems to be missing (babashka.process/*defaults* though is working fine).

Another idea discussed in slack is whether it will also be a good idea to include convenience fn such as

(babashka.process/set-default :echo true)

Thanks

ikappaki avatar Mar 04 '23 10:03 ikappaki

Yes to both.

Also:

(babashka.process/shell {:echo true} "ls" "-al)
;; => /usr/bin/ls -al

Should we print ls as the user has written it, or the resolved program, like process finds it?

borkdude avatar Mar 04 '23 10:03 borkdude

Perhaps we could support both? I find the full path command useful but it could be too much for some users. Would it be a good idea to have :echo false :echo true :echo :verbose as options?

ikappaki avatar Mar 04 '23 10:03 ikappaki

(:verbose/full/resolve whatever word is most appropriate)

ikappaki avatar Mar 04 '23 10:03 ikappaki