|
228 | 228 | " try:\n", |
229 | 229 | " ensure(not (disallow_re and re.search(disallow_re, argstr)), 'args disallowed')\n", |
230 | 230 | " ensure(not (allow_re and re.search( allow_re, argstr)), 'args not allowed')\n", |
231 | | - " outp = run([cmd] + split(argstr), text=True, stdin=DEVNULL, capture_output=True)\n", |
| 231 | + " args = [str(Path(a).expanduser()) if a.startswith('~') else a for a in split(argstr)]\n", |
| 232 | + " outp = run([cmd] + args, text=True, stdin=DEVNULL, capture_output=True)\n", |
232 | 233 | " except: return explain_exc(f'running cmd')\n", |
233 | 234 | " res = outp.stdout\n", |
234 | 235 | " if res and outp.stderr: res += '\\n'\n", |
|
253 | 254 | "name": "stdout", |
254 | 255 | "output_type": "stream", |
255 | 256 | "text": [ |
256 | | - "\u001b[34m__pycache__\u001b[m\u001b[m\n", |
257 | | - "_parallel_win.ipynb\n", |
258 | | - "_quarto.yml\n", |
259 | | - "00_test.ipynb\n", |
260 | | - "000_tour.ipynb\n", |
261 | | - "01_basics.ipynb\n", |
262 | | - "02_foundation.ipynb\n", |
263 | | - "03_xtras\n" |
| 257 | + "\u001b[34maai-ws\u001b[m\u001b[m\n", |
| 258 | + "\u001b[34mApplications\u001b[m\u001b[m\n", |
| 259 | + "autoexec.ipynb\n", |
| 260 | + "\u001b[34mbooks\u001b[m\u001b[m\n", |
| 261 | + "cachy.jsonl\n", |
| 262 | + "\u001b[34mchats\u001b[m\u001b[m\n", |
| 263 | + "CRAFT.ipynb\n", |
| 264 | + "\u001b[34mDesktop\u001b\n" |
264 | 265 | ] |
265 | 266 | } |
266 | 267 | ], |
267 | 268 | "source": [ |
268 | | - "print(run_cmd('ls')[:128])" |
| 269 | + "print(run_cmd('ls', '~')[:128])" |
269 | 270 | ] |
270 | 271 | }, |
271 | 272 | { |
272 | 273 | "cell_type": "markdown", |
273 | 274 | "id": "ee40009c", |
274 | 275 | "metadata": {}, |
275 | 276 | "source": [ |
276 | | - "Note that, for tool safety, this is not passed through the shell, so wildcards, env vars, etc will not work:" |
| 277 | + "Note that, for tool safety, this is not passed through the shell, so wildcards, env vars, etc will not work (although `~` will):" |
277 | 278 | ] |
278 | 279 | }, |
279 | 280 | { |
|
0 commit comments