patch 9.0.0244: cannot easily get the list of sourced scripts

Problem:    Cannot easily get the list of sourced scripts.
Solution:   Add the getscriptinfo() function. (Yegappan Lakshmanan,
            closes #10957)
diff --git a/src/evalfunc.c b/src/evalfunc.c
index a5c8a7d..c199bdb 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -1935,6 +1935,8 @@
 			ret_dict_any,	    f_getreginfo},
     {"getregtype",	0, 1, FEARG_1,	    arg1_string,
 			ret_string,	    f_getregtype},
+    {"getscriptinfo",	0, 0, 0,	    NULL,
+			ret_list_dict_any,  f_getscriptinfo},
     {"gettabinfo",	0, 1, FEARG_1,	    arg1_number,
 			ret_list_dict_any,  f_gettabinfo},
     {"gettabvar",	2, 3, FEARG_1,	    arg3_number_string_any,
diff --git a/src/proto/scriptfile.pro b/src/proto/scriptfile.pro
index 205028d..c80ed8c 100644
--- a/src/proto/scriptfile.pro
+++ b/src/proto/scriptfile.pro
@@ -33,6 +33,7 @@
 void free_scriptnames(void);
 void free_autoload_scriptnames(void);
 linenr_T get_sourced_lnum(char_u *(*fgetline)(int, void *, int, getline_opt_T), void *cookie);
+void f_getscriptinfo(typval_T *argvars, typval_T *rettv);
 char_u *getsourceline(int c, void *cookie, int indent, getline_opt_T options);
 int sourcing_a_script(exarg_T *eap);
 void ex_scriptencoding(exarg_T *eap);
diff --git a/src/scriptfile.c b/src/scriptfile.c
index 76c78e7..aae3be2 100644
--- a/src/scriptfile.c
+++ b/src/scriptfile.c
@@ -1933,6 +1933,36 @@
 			? ((source_cookie_T *)cookie)->sourcing_lnum
 			: SOURCING_LNUM;
 }
+
+    void
+f_getscriptinfo(typval_T *argvars UNUSED, typval_T *rettv)
+{
+    int		i;
+    list_T	*l;
+
+    if (rettv_list_alloc(rettv) == FAIL)
+	return;
+
+    l = rettv->vval.v_list;
+
+    for (i = 1; i <= script_items.ga_len; ++i)
+    {
+	scriptitem_T	*si = SCRIPT_ITEM(i);
+	dict_T		*d;
+
+	if (si->sn_name == NULL)
+	    continue;
+
+	if ((d = dict_alloc()) == NULL
+		|| list_append_dict(l, d) == FAIL
+		|| dict_add_string(d, "name", si->sn_name) == FAIL
+		|| dict_add_number(d, "sid", i) == FAIL
+		|| dict_add_bool(d, "autoload",
+				si->sn_state == SN_STATE_NOT_LOADED) == FAIL)
+	    return;
+    }
+}
+
 #endif
 
     static char_u *
diff --git a/src/testdir/test_scriptnames.vim b/src/testdir/test_scriptnames.vim
index 44ec146..06ae305 100644
--- a/src/testdir/test_scriptnames.vim
+++ b/src/testdir/test_scriptnames.vim
@@ -1,5 +1,5 @@
-" Test for :scriptnames
 
+" Test for the :scriptnames command
 func Test_scriptnames()
   call writefile(['let did_load_script = 123'], 'Xscripting')
   source Xscripting
@@ -29,4 +29,14 @@
   call assert_equal(msgs, execute('messages'))
 endfunc
 
+" Test for the getscriptinfo() function
+func Test_getscriptinfo()
+  call writefile(['let loaded_script_id = expand("<SID>")'], 'Xscript')
+  source Xscript
+  let l = getscriptinfo()
+  call assert_match('Xscript$', l[-1].name)
+  call assert_equal(g:loaded_script_id, $"<SNR>{l[-1].sid}_")
+  call delete('Xscript')
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim
index f28b4ad..4cc53b2 100644
--- a/src/testdir/test_vim9_import.vim
+++ b/src/testdir/test_vim9_import.vim
@@ -732,6 +732,8 @@
 
   source Xmapscript.vim
   assert_match('\d\+ A: .*XrelautoloadExport.vim', execute('scriptnames')->split("\n")[-1])
+  assert_match('XrelautoloadExport.vim$', getscriptinfo()[-1].name)
+  assert_true(getscriptinfo()[-1].autoload)
   feedkeys("\<F3>", "xt")
   assert_equal(42, g:result)
 
diff --git a/src/version.c b/src/version.c
index a5392e6..e2882b6 100644
--- a/src/version.c
+++ b/src/version.c
@@ -732,6 +732,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    244,
+/**/
     243,
 /**/
     242,