@@ -1820,12 +1820,14 @@ nvm_print_versions() {
18201820 fi
18211821
18221822 command awk \
1823- -v remote_versions=" $( printf ' %s' " ${1-} " | tr ' \n' ' |' ) " \
1823+ -v remote_versions=" $( printf ' %s' " ${1-} " | tr ' \n' ' |' ) " -v min_ver= " ${NVM_MIN_VER :- v0} " \
18241824 -v installed_versions=" $( nvm_ls | tr ' \n' ' |' ) " -v current=" $NVM_CURRENT " \
18251825 -v installed_color=" $INSTALLED_COLOR " -v system_color=" $SYSTEM_COLOR " \
18261826 -v current_color=" $CURRENT_COLOR " -v default_color=" $DEFAULT_COLOR " \
18271827 -v old_lts_color=" $DEFAULT_COLOR " -v has_colors=" $NVM_HAS_COLORS " '
18281828function alen(arr, i, len) { len=0; for(i in arr) len++; return len; }
1829+ function v2a(v, a) { sub(/^(iojs-)?v/, "", v); split(v, a, "."); }
1830+ 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; }
18291831BEGIN {
18301832 fmt_installed = has_colors ? (installed_color ? "\033[" installed_color "%15s\033[0m" : "%15s") : "%15s *";
18311833 fmt_system = has_colors ? (system_color ? "\033[" system_color "%15s\033[0m" : "%15s") : "%15s *";
@@ -1840,13 +1842,15 @@ BEGIN {
18401842 split(remote_versions, lines, "|");
18411843 split(installed_versions, installed, "|");
18421844 rows = alen(lines);
1843-
1844- for (n = 1; n <= rows; n++) {
1845+ filter = (min_ver != "v0");
1846+ for (m = n = 1; n <= rows; n++) {
18451847 split(lines[n], fields, "[[:blank:]]+");
18461848 cols = alen(fields);
18471849 version = fields[1];
1848- is_installed = 0 ;
1850+ if (filter && comp(version, min_ver) < 0) continue ;
18491851
1852+ filter = 0;
1853+ is_installed = 0;
18501854 for (i in installed) {
18511855 if (version == installed[i]) {
18521856 is_installed = 1;
@@ -1863,8 +1867,7 @@ BEGIN {
18631867 fmt_version = fmt_installed;
18641868 }
18651869
1866- padding = (!has_colors && is_installed) ? "" : " ";
1867-
1870+ padding = (is_installed && !has_colors) ? "" : " ";
18681871 if (cols == 1) {
18691872 formatted = sprintf(fmt_version, version);
18701873 } else if (cols == 2) {
@@ -1873,11 +1876,11 @@ BEGIN {
18731876 formatted = sprintf((fmt_version padding fmt_latest_lts), version, fields[2]);
18741877 }
18751878
1876- output[n ] = formatted;
1879+ output[m++ ] = formatted;
18771880 }
18781881
1879- for (n = 1; n <= rows; n++ ) {
1880- print output[n ]
1882+ for (m in output ) {
1883+ print output[m ]
18811884 }
18821885
18831886 exit
0 commit comments