Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

You're looking for set -x:

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

See the tutorial section on environment variables for more.

share|improve this answer
    
Though it sounds like it's what the OP is asking, I don't think it is what he wants. –  Stéphane Chazelas Jun 17 at 9:07

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.