Fix append only once

[GitHub #76]
This commit is contained in:
Aoran Zeng
2024-11-22 02:04:36 +08:00
parent c1c495cf6d
commit 7825acfff3
7 changed files with 57 additions and 42 deletions

View File

@@ -48,13 +48,14 @@ wr_homebrew_setsrc (char *option)
{
chsrc_yield_source_and_confirm (wr_homebrew);
char *splitter = "\n\n# Generated by chsrc " Chsrc_Banner_Version;
char *w1 = xy_strjoin (3, "export HOMEBREW_API_DOMAIN=\"", source.url, "homebrew-bottles/api", "\"\n");
char *w2 = xy_strjoin (3, "export HOMEBREW_BOTTLE_DOMAIN=\"", source.url, "homebrew-bottles", "\"\n");
char *w3 = xy_strjoin (3, "export HOMEBREW_BREW_GIT_REMOTE=\"", source.url, "git/homebrew/brew.git", "\"\n");
char *w4 = xy_strjoin (3, "export HOMEBREW_CORE_GIT_REMOTE=\"", source.url, "git/homebrew/homebrew-core.git", "\"\n");
char *splitter = "\n# --- chsrc BLOCK BEGIN for Homebrew ---\n";
char *w1 = xy_strjoin (4, "export HOMEBREW_API_DOMAIN=\"", source.url, "homebrew-bottles/api", "\"\n");
char *w2 = xy_strjoin (4, "export HOMEBREW_BOTTLE_DOMAIN=\"", source.url, "homebrew-bottles", "\"\n");
char *w3 = xy_strjoin (4, "export HOMEBREW_BREW_GIT_REMOTE=\"", source.url, "git/homebrew/brew.git", "\"\n");
char *w4 = xy_strjoin (4, "export HOMEBREW_CORE_GIT_REMOTE=\"", source.url, "git/homebrew/homebrew-core.git", "\"\n");
char *end = "# --- chsrc BLOCK ENDIN for Homebrew ---\n";
char *w = xy_strjoin (5, splitter, w1, w2, w3, w4);
char *w = xy_strjoin (6, splitter, w1, w2, w3, w4, end);
char *zshrc = "~/.zshrc";
chsrc_backup (zshrc);
@@ -70,12 +71,12 @@ wr_homebrew_setsrc (char *option)
char *fishrc = "~/.config/fish/config.fish";
if (xy_file_exist (fishrc))
{
char *w1 = xy_strjoin(3, "set -x HOMEBREW_API_DOMAIN \"", source.url, "homebrew-bottles/api", "\"\n");
char *w2 = xy_strjoin(3, "set -x HOMEBREW_BOTTLE_DOMAIN \"", source.url, "homebrew-bottles", "\"\n");
char *w3 = xy_strjoin(3, "set -x HOMEBREW_BREW_GIT_REMOTE \"",source.url, "git/homebrew/brew.git", "\"\n");
char *w4 = xy_strjoin(3, "set -x HOMEBREW_CORE_GIT_REMOTE \"",source.url, "git/homebrew/homebrew-core.git", "\"\n");
char *w1 = xy_strjoin(4, "set -x HOMEBREW_API_DOMAIN \"", source.url, "homebrew-bottles/api", "\"\n");
char *w2 = xy_strjoin(4, "set -x HOMEBREW_BOTTLE_DOMAIN \"", source.url, "homebrew-bottles", "\"\n");
char *w3 = xy_strjoin(4, "set -x HOMEBREW_BREW_GIT_REMOTE \"",source.url, "git/homebrew/brew.git", "\"\n");
char *w4 = xy_strjoin(4, "set -x HOMEBREW_CORE_GIT_REMOTE \"",source.url, "git/homebrew/homebrew-core.git", "\"\n");
char *w = xy_strjoin (5, splitter, w1, w2, w3, w4);
char *w = xy_strjoin (6, splitter, w1, w2, w3, w4, end);
chsrc_backup (fishrc);
chsrc_append_to_file (w, fishrc);
}