Popovici Sebi
Popovici Sebi

Reputation: 258

How to set a "variable" that can be commited on git in linux?

I have a hardcoded the name of a folder for versions in a .sh script , so when I want to switch to other version I have to change it manually in all the files , what is the best way to set a "variable" that can be commited on git ? Now in my files it is something like : program/1.0.0/ And I want to make it like : program/$latest_version I tried with a symbolic link , I don't know pretty much bash , and I cannot take the value : ln -s 1.0.0/ latest_version

Upvotes: 0

Views: 78

Answers (2)

Popovici Sebi
Popovici Sebi

Reputation: 258

I managed to use the symbolic link like this: (ln -s 1.0.0/ latest_version)//creation of link program/$(readlink latest_version)// using it in script

Upvotes: 1

hek2mgl
hek2mgl

Reputation: 157947

I would add a file called conf.dist.sh to your repository, like this:

FOLDER_NAME="default-folder-name"

On top of your script source that file:

#!/bin/bash
source "conf.sh"

When you clone the repository, copy conf.dist.sh to conf.sh, change to folder name according to your needs but don't add conf.sh to git to avoid conflicts.

Upvotes: 4

Related Questions