pkg -oABI fails on amd64 in csh because of $(uname -p)

Related to this howto: https://www.freebsd.org/releases/15.1R/upgrading/

On amd64 you get this:

Code:
# pkg -oABI=FreeBSD:15:$(uname -p) -oOSVERSION=1501000 upgrade -r FreeBSD-base
Illegal variable name.

# echo $(uname -p)
Illegal variable name.

The fix is to use the backticks:

Code:
# pkg -oABI=FreeBSD:15:`uname -p` -oOSVERSION=1501000 upgrade -r FreeBSD-base
 
Besides that, for some time sh(1) is the default shell for root in FreeBSD.
I believe the switch for root from csh to sh was in 14.X so not really "for some time" because from 1.x to 13.X root default shell was csh.

bugzeo yes it's a "$SHELL" thing. the syntax you post is sh syntax which fails if shell is csh. Easy way to tell:
"echo $SHELL"
If it says csh/tcsh then syntax is wrong the "$() construct"

Tell us the output on the system you are trying to upgrade for:
freebsd-version
echo $SHELL
 
In amd64 the shell is csh and in arm64 is sh but i think could be caused by updating an old FreeBSD system when had the other shell as default. Still the commands can be made common for all shells.
 
The commands are common for both shells.
The problem is "shell expansion".

the $(uname -p) construct is sh for "run this command and substitute the output in the pkg command"
the backticks construct is csh for "run this command and substitute the output in the pkg command"

It's not the pkg command that is "the problem", the problem is "how do I do this in whatever shell I'm running.
You're asking for csh to understand sh syntax and sh to understand csh syntax.
 
It is pkg feature and it works, when ABI and OSVERSION options specified in the same time.
I've seen you reply, that the backtick is used for code markdown syntax. A better way to avoid that issue would be to use the shell directly in the command:

Code:
sh -c 'pkg -oABI=FreeBSD:15:$(uname -p) -oOSVERSION=1501000 upgrade -r FreeBSD-base'

This doesn't interfere with markdown, and I don't use "/bin/sh" because could interfere with slash commands, if you paste that onto Discord or IRC.

If you want to set the path directly:

Code:
env /bin/sh -c 'pkg -oABI=FreeBSD:15:$(uname -p) -oOSVERSION=1501000 upgrade -r FreeBSD-base'
 
Using backticks is perfectly fine, markdown didn't exist when those shells were designed, and any newer text formats could use $ or / so I don't think the documentation shouldn't care about that.
 
Back
Top