3

I want to use following in fish shell:

$ export arm='ARCH=arm CROSS_COMPILE=arm-eabi-'
$ make $arm 

This works fine in bash/zsh but not on fish shell.

But if I execute the following in fish shell:

$env tmp=arm make

this works fine.

Can someone please help me with this?

TPS
  • 2,483
  • 5
  • 27
  • 45
user3202436
  • 31
  • 1
  • 3

2 Answers2

5

You're looking for set -x:

set -x arm 'ARCH=arm CROSS_COMPILE=arm-eabi-'

See the tutorial section on environment variables for more.

ridiculous_fish
  • 1,661
  • 10
  • 15
3

In sh/bash:

export arm='ARCH=arm CROSS_COMPILE=arm-eabi-'
make $arm

Doesn't really make sense. Environment variables are meant as variables passed to make (so a reference to $(arm) in the Makefile for instance expands to its content). Environment variables are scalar, they can contain only one string value. Above you're relying on the split+glob operator of the shell that splits the variable into words passed to make (as arguments).

But $arm is expanded by the shell, so you don't need to export arm to the environment of make because make makes no use of that $arm variable.

Also, on a shell that supports them, it would make more sense to use arrays. In bash /zsh/ksh:

arm=(ARCH=arm CROSS_COMPILE=arm-eabi-)
make "${arm[@]}"

With fish:

set arm ARCH=arm CROSS_COMPILE=arm-eabi-
make $arm

With rc/es/zsh:

arm=(ARCH=arm CROSS_COMPILE=arm-eabi-)
make $arm
Stéphane Chazelas
  • 522,931
  • 91
  • 1,010
  • 1,501