From ee670bc1c6dcbd56da0b203dea19e690450b21ed Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 13 Feb 2022 15:10:15 +0100 Subject: [PATCH] pySim-shell: Allow selecting of deep paths like DF.GSM/EF.IMSI With this patch applied, users can directly enter commands like select DF.GSM/EF.IMSI or select ADF.USIM/DF.5GS/EF.5GAUTHKEYS This feature doesn't have tabl completion, so it's mostly useful for when you know what to select, or for use within scripts. Change-Id: I681a132eb2df4b2aba4c2ccbdd21c6d5b88443e3 --- pySim/filesystem.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pySim/filesystem.py b/pySim/filesystem.py index d1c3e1fd..bef9005d 100644 --- a/pySim/filesystem.py +++ b/pySim/filesystem.py @@ -1411,6 +1411,22 @@ class RuntimeState(object): name : Name of file to select cmd_app : Command Application State (for unregistering old file commands) """ + # handling of entire paths with multiple directories/elements + if '/' in name: + prev_sel_file = self.selected_file + pathlist = name.split('/') + # treat /DF.GSM/foo like MF/DF.GSM/foo + if pathlist[0] == '': + pathlist[0] = 'MF' + try: + for p in pathlist: + self.select(p, cmd_app) + return + except Exception as e: + # if any intermediate step fails, go back to where we were + self.select_file(prev_sel_file, cmd_app) + raise e + sels = self.selected_file.get_selectables() if is_hex(name): name = name.lower()