Git using for aliases different shell than bash

Cube94

I am learning git for some time, recently I have been using aliases. Everything was working, until last time. My example alias stopped working ( git simple-commit works fine )

simple-loop = "!simpleLoop() { NAME=$1; i="1"; while [ $i -le $2 ]; do git simple-commit $NAME$i; i=$[$i+1]; done; }; simpleLoop"

I am getting fatal in terminal

simpleLoop() { NAME=$1; i=1; while [ $i -le $2 ]; do git simple-commit $NAME$i; i=$[$i+1]; done; }; 
simpleLoop: 1: [: Illegal number: $[1+1]

It looks like git not using bash shell. Any idea what is going on ?

VonC

I just tested a simplified version of that alias:

aa = "!simpleLoop() { i="1"; while [ $i -le "4" ]; do echo $i; i=$[$i+1]; done; }; simpleLoop"

And git aa does give the expected result:

D:\git\>git aa
1
2
3
4

To be sure, assuming Git for Windows, test your alias in a CMD session with a simplified PATH:

set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set GH=C:\path\to\git
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\cmd;%GH%\mingw64\bin;%PATH%

You can also use a number for i (i=1 instead of "1") and use other syntax to increment that variable (like i=$((i+1)))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

aliases in bash shell not working

What are the parentheses used for in a bash shell script function definition like "f () {}"? Is it different than using the "function" keyword?

git using different version of vim than zsh

Git bash on Windows different result than terminal on CentOS for regex

aliases do not work in bash - login shell

Shell provision script not creating .bash_aliases

Vim is not using Bash's aliases

How to set aliases in the Git Bash for Windows?

Bash completion for git aliases containing multiple subcommands

Define bash aliases to run git as specific user

Can I used more than 1 account using git bash

Send Mail from Windows Machine using Shell ( from Git bash)

Creating shared library fails in Git Bash shell using Makefile

Call Batch Script from Shell Script using Git Bash

shell_exec() not returning correct results using Git-Bash

Why does escaping double quotes from Python's run (with shell=True) is different than in Bash?

How to use bash aliases in a non-interactive shell?

Using "$@" in bash function has different result than directly running command in bash

Shell script written in a different shell than what my current shell

$SHELL in tmux is different than $SHELL in the shell that I launched it from

Chatting using Bash Shell?

Using Python Shell in Bash

VSCode terminal windows - git-bash aliases getting ignored

How can I use git bash aliases in vscode terminal?

Calling CMD and passing inputs to EXE from a Bash shell script (using Git Bash for Windows)

Having aliases active in a terminal session without using bashrc or bash_profile or bash_aliases?

IPython uses a different $PATH environment than the shell

macOS vim locale different than shell

Is dash or some other shell "faster" than bash?