I have a bash script like
#!/bin/bash
DATABASE_NAME=my_database
export DATABASE_NAME
run_some_other_command
They first declare the variable and set it to a value, then in a separate line, they export it. Personally, I like to just do it in one line like:
export DATABASE_NAME=my_database
Is there some style rule against this? I've seen the declaration and export be separated by others, but never knew why.
If it helps, this script runs on Linux Mint, but could run on other Linux's or even a Mac.
exportcommands. Some older shell may not have, which may have led to a belief thatexportmust still be done separately from assignment.exporteven when it isn't needed; I wouldn't take a random sample ofbashscripts in the wild as indicative of anything resembling good practice.~/.profileand~/.bash_profilein some Linux distros