It is common to use created ipfs hash exactly after ipfs add some_file command.
Why dont ipfs autoset bash variable like $hash or $ipfshash or $_ (python style), so I will be able to easily use it?
It is common to use created ipfs hash exactly after ipfs add some_file command.
Why dont ipfs autoset bash variable like $hash or $ipfshash or $_ (python style), so I will be able to easily use it?
Are you looking for something easier than this?
hash=$(ipfs add -Q some_file)
I’m not aware of other command-line applications setting variables like what you’re asking for, but if you have examples of this being a standard practice I’d be interested in knowing this is something I can use in my own scripts elsewhere.
No, subprocesses cannot set cariables in a calling shell process. What people do is they print out shell statements and the caller evals them. Look at e.g. ssh-agent when run without a command argument.
Or if it’s only one value, just print out the value, as you just showed ipfs add does already.