最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

csh - modulefile set-alias with variables problem - Stack Overflow

programmeradmin1浏览0评论

Using modules with csh shell. csh not my choice, cannot change that.

I want to keep the $jobRunName as exactly that in the alias, so in the shell that can be a shell env var to use there.

set-alias seems to want to change $ into !!, I have not found anything about that anywhere in the googlez.

In the modulefile loaded:

set queueNameBatch "testQueue"
set jobRunName "\$jobRunName"
set jobQcmd             "sbatch -o ./logs/srun.%j.log -e ./logs/srun.%j.err -J $jobRunName -p "
set-alias qt "$jobQcmd $queueNameBatch "
which qt
qt:      aliased to sbatch -o ./logs/srun.%j.log -e ./logs/srun.%j.err -J !!:jobRunName -p  testQueue 

I had previously tried {} instead of "" around he alias string but that just gave me

set-alias qt {$jobQcmd $queueNameBatch }

which qt
qt:      aliased to !!:jobQcmd !!:queueNameBatch 

So the doublequotes seem better here

Any idea how to fix this so !!: goes back to the intended $ sign?

Using modules with csh shell. csh not my choice, cannot change that.

I want to keep the $jobRunName as exactly that in the alias, so in the shell that can be a shell env var to use there.

set-alias seems to want to change $ into !!, I have not found anything about that anywhere in the googlez.

In the modulefile loaded:

set queueNameBatch "testQueue"
set jobRunName "\$jobRunName"
set jobQcmd             "sbatch -o ./logs/srun.%j.log -e ./logs/srun.%j.err -J $jobRunName -p "
set-alias qt "$jobQcmd $queueNameBatch "
which qt
qt:      aliased to sbatch -o ./logs/srun.%j.log -e ./logs/srun.%j.err -J !!:jobRunName -p  testQueue 

I had previously tried {} instead of "" around he alias string but that just gave me

set-alias qt {$jobQcmd $queueNameBatch }

which qt
qt:      aliased to !!:jobQcmd !!:queueNameBatch 

So the doublequotes seem better here

Any idea how to fix this so !!: goes back to the intended $ sign?

Share Improve this question asked Feb 2 at 23:06 billtbillt 1011 silver badge
Add a comment  | 

1 Answer 1

Reset to default 0

Modules change variable reference for csh shell. Using puts modulefile command will help to get the exact expected alias code

set qt_alias {sbatch -o ./logs/srun.%j.log -e ./logs/srun.%j.err -J $jobRunName -p testQueue}

if {[module-info shelltype csh] && [module-info mode load]} {
    puts stdout "alias qt \"$qt_alias\";"
} else {
    set-alias qt $qt_alias
}
发布评论

评论列表(0)

  1. 暂无评论