Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define the "=" equals sign as a Bash alias?

I want to define the = equals sign as a Bash alias but Bash does not allow any of the following definitions:

alias =='echo foo'
alias \=='echo foo'
alias -- =='echo foo'
alias -- \=='echo foo'

Does someone know a notation that works?

like image 418
Tim Friske Avatar asked Apr 11 '15 17:04

Tim Friske


2 Answers

This is one of the reserved special chars, used for assignment and test and you cannot use it for alias. More info: http://tldp.org/LDP/abs/html/varassignment.html#EQREF

like image 35
Miglen.com Avatar answered Nov 02 '22 03:11

Miglen.com


Use a function:

=() { echo "foo"; }
like image 69
Cyrus Avatar answered Nov 02 '22 04:11

Cyrus