@@ -1862,79 +1862,79 @@ nvm_print_versions() {
18621862 -v installed_color=" $INSTALLED_COLOR " -v system_color=" $SYSTEM_COLOR " \
18631863 -v current_color=" $CURRENT_COLOR " -v default_color=" $DEFAULT_COLOR " \
18641864 -v old_lts_color=" $DEFAULT_COLOR " -v has_colors=" $NVM_HAS_COLORS " '
1865- function alen(arr, i, len) { len=0; for(i in arr) len++; return len; }
1866- function v2a(v, a) { sub(/^(iojs-)?v/, "", v); split(v, a, "."); }
1867- function v2m(v, a) { sub(/^(iojs-)?v/, "", v); split(v, a, "."); return a[1]; }
1868- 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; }
1869- BEGIN {
1870- fmt_installed = has_colors ? (installed_color ? "\033[" installed_color "%15s\033[0m" : "%15s") : "%15s *";
1871- fmt_system = has_colors ? (system_color ? "\033[" system_color "%15s\033[0m" : "%15s") : "%15s *";
1872- fmt_current = has_colors ? (current_color ? "\033[" current_color "->%13s\033[0m" : "%15s") : "->%13s *";
1873-
1874- latest_lts_color = current_color;
1875- sub(/0;/, "1;", latest_lts_color);
1876-
1877- fmt_latest_lts = has_colors && latest_lts_color ? ("\033[" latest_lts_color " (Latest LTS: %s)\033[0m") : " (Latest LTS: %s)";
1878- fmt_old_lts = has_colors && old_lts_color ? ("\033[" old_lts_color " (LTS: %s)\033[0m") : " (LTS: %s)";
1879-
1880- split(remote_versions, lines, "|");
1881- split(installed_versions, installed, "|");
1882- rows = alen(lines);
1883- filter_on = (vcmp("v0.0.0", min) != 0);
1884- current_major = -1;
1885- for (m = n = 1; n <= rows; n++) {
1886- split(lines[n], fields, "[[:blank:]]+");
1887- cols = alen(fields);
1888- version = fields[1];
1889- is_installed = 0;
1890- for (i in installed) {
1891- if (version == installed[i]) {
1892- is_installed = 1;
1893- break;
1865+ function alen(arr, i, len) { len=0; for(i in arr) len++; return len; }
1866+ function v2a(v, a) { sub(/^(iojs-)?v/, "", v); split(v, a, "."); }
1867+ function v2m(v, a) { sub(/^(iojs-)?v/, "", v); split(v, a, "."); return a[1]; }
1868+ 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; }
1869+ BEGIN {
1870+ fmt_installed = has_colors ? (installed_color ? "\033[" installed_color "%15s\033[0m" : "%15s") : "%15s *";
1871+ fmt_system = has_colors ? (system_color ? "\033[" system_color "%15s\033[0m" : "%15s") : "%15s *";
1872+ fmt_current = has_colors ? (current_color ? "\033[" current_color "->%13s\033[0m" : "%15s") : "->%13s *";
1873+
1874+ latest_lts_color = current_color;
1875+ sub(/0;/, "1;", latest_lts_color);
1876+
1877+ fmt_latest_lts = has_colors && latest_lts_color ? ("\033[" latest_lts_color " (Latest LTS: %s)\033[0m") : " (Latest LTS: %s)";
1878+ fmt_old_lts = has_colors && old_lts_color ? ("\033[" old_lts_color " (LTS: %s)\033[0m") : " (LTS: %s)";
1879+
1880+ split(remote_versions, lines, "|");
1881+ split(installed_versions, installed, "|");
1882+ rows = alen(lines);
1883+ filter_on = (vcmp("v0.0.0", min) != 0);
1884+ current_major = -1;
1885+ for (m = n = 1; n <= rows; n++) {
1886+ split(lines[n], fields, "[[:blank:]]+");
1887+ cols = alen(fields);
1888+ version = fields[1];
1889+ is_installed = 0;
1890+ for (i in installed) {
1891+ if (version == installed[i]) {
1892+ is_installed = 1;
1893+ break;
1894+ }
18941895 }
1895- }
18961896
1897- if (filter_on != 0) {
1898- if (is_installed) {
1899- current_major = v2m(version);
1900- } else if (vcmp(version, min) >= 0) {
1901- filter_on = 0;
1902- } else if (v2m(version) != current_major) {
1903- continue;
1897+ if (filter_on != 0) {
1898+ if (is_installed) {
1899+ current_major = v2m(version);
1900+ } else if (vcmp(version, min) >= 0) {
1901+ filter_on = 0;
1902+ } else if (v2m(version) != current_major) {
1903+ continue;
1904+ }
19041905 }
1905- }
19061906
1907- fmt_version = "%15s";
1908- if (version == current) {
1909- fmt_version = fmt_current;
1910- } else if (version == "system") {
1911- fmt_version = fmt_system;
1912- } else if (is_installed) {
1913- fmt_version = fmt_installed;
1914- }
1907+ fmt_version = "%15s";
1908+ if (version == current) {
1909+ fmt_version = fmt_current;
1910+ } else if (version == "system") {
1911+ fmt_version = fmt_system;
1912+ } else if (is_installed) {
1913+ fmt_version = fmt_installed;
1914+ }
19151915
1916- padding = (is_installed && !has_colors) ? "" : " ";
1917- if (cols == 1) {
1918- formatted = sprintf(fmt_version, version);
1919- } else if (cols == 2) {
1920- formatted = sprintf((fmt_version padding fmt_old_lts), version, fields[2]);
1921- } else if (cols == 3 && fields[3] == "*") {
1922- formatted = sprintf((fmt_version padding fmt_latest_lts), version, fields[2]);
1923- }
1916+ padding = (is_installed && !has_colors) ? "" : " ";
1917+ if (cols == 1) {
1918+ formatted = sprintf(fmt_version, version);
1919+ } else if (cols == 2) {
1920+ formatted = sprintf((fmt_version padding fmt_old_lts), version, fields[2]);
1921+ } else if (cols == 3 && fields[3] == "*") {
1922+ formatted = sprintf((fmt_version padding fmt_latest_lts), version, fields[2]);
1923+ }
19241924
1925- output[m++] = formatted;
1926- }
1925+ output[m++] = formatted;
1926+ }
19271927
1928- for (n = 1; n < m; n++) {
1929- print output[n]
1930- }
1928+ for (n = 1; n < m; n++) {
1929+ print output[n]
1930+ }
19311931
1932- if (rows > --m) {
1933- printf("[INFO] showing %d (of %d) versions.\n", m, rows) > "/dev/stderr"
1934- }
1932+ if (rows > --m) {
1933+ printf("[INFO] showing %d (of %d) versions.\n", m, rows) > "/dev/stderr"
1934+ }
19351935
1936- exit
1937- }'
1936+ exit
1937+ }'
19381938}
19391939
19401940nvm_validate_implicit_alias () {
0 commit comments