Skip to content

Commit 51726ed

Browse files
committed
indent awk script properly
1 parent 11418c6 commit 51726ed

1 file changed

Lines changed: 64 additions & 64 deletions

File tree

nvm.sh

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,79 +1897,79 @@ nvm_print_versions() {
18971897
-v installed_color="$INSTALLED_COLOR" -v system_color="$SYSTEM_COLOR" \
18981898
-v current_color="$CURRENT_COLOR" -v default_color="$DEFAULT_COLOR" \
18991899
-v old_lts_color="$DEFAULT_COLOR" -v has_colors="$NVM_HAS_COLORS" '
1900-
function alen(arr, i, len) { len=0; for(i in arr) len++; return len; }
1901-
function v2a(v, a) { sub(/^(iojs-)?v/, "", v); split(v, a, "."); }
1902-
function v2m(v, a) { sub(/^(iojs-)?v/, "", v); split(v, a, "."); return a[1]; }
1903-
function vcmp(v1,v2,a1,a2,i,d) { v2a(v1,a1); v2a(v2,a2); for(i=1;i<4;i++) { d = a1[i] - a2[i]; if(d!=0) return d; } return 0; }
1904-
BEGIN {
1905-
fmt_installed = has_colors ? (installed_color ? "\033[" installed_color "%15s\033[0m" : "%15s") : "%15s *";
1906-
fmt_system = has_colors ? (system_color ? "\033[" system_color "%15s\033[0m" : "%15s") : "%15s *";
1907-
fmt_current = has_colors ? (current_color ? "\033[" current_color "->%13s\033[0m" : "%15s") : "->%13s *";
1908-
1909-
latest_lts_color = current_color;
1910-
sub(/0;/, "1;", latest_lts_color);
1911-
1912-
fmt_latest_lts = has_colors && latest_lts_color ? ("\033[" latest_lts_color " (Latest LTS: %s)\033[0m") : " (Latest LTS: %s)";
1913-
fmt_old_lts = has_colors && old_lts_color ? ("\033[" old_lts_color " (LTS: %s)\033[0m") : " (LTS: %s)";
1914-
1915-
split(remote_versions, lines, "|");
1916-
split(installed_versions, installed, "|");
1917-
rows = alen(lines);
1918-
filter_on = (vcmp("v0.0.0", min) != 0);
1919-
current_major = -1;
1920-
for (m = n = 1; n <= rows; n++) {
1921-
split(lines[n], fields, "[[:blank:]]+");
1922-
cols = alen(fields);
1923-
version = fields[1];
1924-
is_installed = 0;
1925-
for (i in installed) {
1926-
if (version == installed[i]) {
1927-
is_installed = 1;
1928-
break;
1900+
function alen(arr, i, len) { len=0; for(i in arr) len++; return len; }
1901+
function v2a(v, a) { sub(/^(iojs-)?v/, "", v); split(v, a, "."); }
1902+
function v2m(v, a) { sub(/^(iojs-)?v/, "", v); split(v, a, "."); return a[1]; }
1903+
function vcmp(v1,v2,a1,a2,i,d) { v2a(v1,a1); v2a(v2,a2); for(i=1;i<4;i++) { d = a1[i] - a2[i]; if(d!=0) return d; } return 0; }
1904+
BEGIN {
1905+
fmt_installed = has_colors ? (installed_color ? "\033[" installed_color "%15s\033[0m" : "%15s") : "%15s *";
1906+
fmt_system = has_colors ? (system_color ? "\033[" system_color "%15s\033[0m" : "%15s") : "%15s *";
1907+
fmt_current = has_colors ? (current_color ? "\033[" current_color "->%13s\033[0m" : "%15s") : "->%13s *";
1908+
1909+
latest_lts_color = current_color;
1910+
sub(/0;/, "1;", latest_lts_color);
1911+
1912+
fmt_latest_lts = has_colors && latest_lts_color ? ("\033[" latest_lts_color " (Latest LTS: %s)\033[0m") : " (Latest LTS: %s)";
1913+
fmt_old_lts = has_colors && old_lts_color ? ("\033[" old_lts_color " (LTS: %s)\033[0m") : " (LTS: %s)";
1914+
1915+
split(remote_versions, lines, "|");
1916+
split(installed_versions, installed, "|");
1917+
rows = alen(lines);
1918+
filter_on = (vcmp("v0.0.0", min) != 0);
1919+
current_major = -1;
1920+
for (m = n = 1; n <= rows; n++) {
1921+
split(lines[n], fields, "[[:blank:]]+");
1922+
cols = alen(fields);
1923+
version = fields[1];
1924+
is_installed = 0;
1925+
for (i in installed) {
1926+
if (version == installed[i]) {
1927+
is_installed = 1;
1928+
break;
1929+
}
19291930
}
1930-
}
19311931
1932-
if (filter_on != 0) {
1933-
if (is_installed) {
1934-
current_major = v2m(version);
1935-
} else if (vcmp(version, min) >= 0) {
1936-
filter_on = 0;
1937-
} else if (v2m(version) != current_major) {
1938-
continue;
1932+
if (filter_on != 0) {
1933+
if (is_installed) {
1934+
current_major = v2m(version);
1935+
} else if (vcmp(version, min) >= 0) {
1936+
filter_on = 0;
1937+
} else if (v2m(version) != current_major) {
1938+
continue;
1939+
}
19391940
}
1940-
}
19411941
1942-
fmt_version = "%15s";
1943-
if (version == current) {
1944-
fmt_version = fmt_current;
1945-
} else if (version == "system") {
1946-
fmt_version = fmt_system;
1947-
} else if (is_installed) {
1948-
fmt_version = fmt_installed;
1949-
}
1942+
fmt_version = "%15s";
1943+
if (version == current) {
1944+
fmt_version = fmt_current;
1945+
} else if (version == "system") {
1946+
fmt_version = fmt_system;
1947+
} else if (is_installed) {
1948+
fmt_version = fmt_installed;
1949+
}
19501950
1951-
padding = (is_installed && !has_colors) ? "" : " ";
1952-
if (cols == 1) {
1953-
formatted = sprintf(fmt_version, version);
1954-
} else if (cols == 2) {
1955-
formatted = sprintf((fmt_version padding fmt_old_lts), version, fields[2]);
1956-
} else if (cols == 3 && fields[3] == "*") {
1957-
formatted = sprintf((fmt_version padding fmt_latest_lts), version, fields[2]);
1958-
}
1951+
padding = (is_installed && !has_colors) ? "" : " ";
1952+
if (cols == 1) {
1953+
formatted = sprintf(fmt_version, version);
1954+
} else if (cols == 2) {
1955+
formatted = sprintf((fmt_version padding fmt_old_lts), version, fields[2]);
1956+
} else if (cols == 3 && fields[3] == "*") {
1957+
formatted = sprintf((fmt_version padding fmt_latest_lts), version, fields[2]);
1958+
}
19591959
1960-
output[m++] = formatted;
1961-
}
1960+
output[m++] = formatted;
1961+
}
19621962
1963-
for (n = 1; n < m; n++) {
1964-
print output[n]
1965-
}
1963+
for (n = 1; n < m; n++) {
1964+
print output[n]
1965+
}
19661966
1967-
if (rows > --m) {
1968-
printf("[INFO] showing %d (of %d) versions.\n", m, rows) > "/dev/stderr"
1969-
}
1967+
if (rows > --m) {
1968+
printf("[INFO] showing %d (of %d) versions.\n", m, rows) > "/dev/stderr"
1969+
}
19701970
1971-
exit
1972-
}'
1971+
exit
1972+
}'
19731973
}
19741974

19751975
nvm_validate_implicit_alias() {

0 commit comments

Comments
 (0)