{"id":19144035,"url":"https://github.com/sourlemonjuice/specifyrm","last_synced_at":"2025-07-30T11:06:30.684Z","repository":{"id":225488381,"uuid":"766021498","full_name":"SourLemonJuice/specifyRM","owner":"SourLemonJuice","description":"Confirm the target meets your expectations before rm | 在rm前确认目标符合自己的预期","archived":false,"fork":false,"pushed_at":"2024-03-02T10:45:49.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-22T19:31:25.224Z","etag":null,"topics":["rm","shell-script"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SourLemonJuice.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-02T05:50:29.000Z","updated_at":"2024-03-02T10:59:53.000Z","dependencies_parsed_at":"2024-03-02T12:45:03.617Z","dependency_job_id":"023e2ca9-62ab-40ab-817a-fcea6b34a2c7","html_url":"https://github.com/SourLemonJuice/specifyRM","commit_stats":null,"previous_names":["sourlemonjuice/specifyrm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SourLemonJuice/specifyRM","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SourLemonJuice%2FspecifyRM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SourLemonJuice%2FspecifyRM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SourLemonJuice%2FspecifyRM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SourLemonJuice%2FspecifyRM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SourLemonJuice","download_url":"https://codeload.github.com/SourLemonJuice/specifyRM/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SourLemonJuice%2FspecifyRM/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267858029,"owners_count":24155916,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rm","shell-script"],"created_at":"2024-11-09T07:33:20.759Z","updated_at":"2025-07-30T11:06:30.643Z","avatar_url":"https://github.com/SourLemonJuice.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# specifyRM\n\n## 1.介绍\n\n为了更放心的在脚本中使用`rm`所搓的东西啦\\\nspecify 是指在删除前确认路径是否符合预期，比如要删除`/tmp/test233/`文件夹就在删除前验证路径是否以`/tmp`开头或者以`test233`结尾\\\n在理论上路径中有部分不变的删除操作时，加个检测也更安心一点吧，万一你的变量被神秘力量改成`/usr`或者`NULL`之类的就不好玩了\n\n写这个是因为想起之前写某个脚本时就因为rm的参数是变量，就在debug的时候来回注释rm的那一行...\\\n反正有空，写个检测脚本以后还能用的上\n\n## 2.函数说明\n\n目前项目有两个函数\n\n- specifyRM_match\\\n  负责匹配判断条件，只返回状态码，这也是理想中最常用的功能\n- specifyRM\\\n  执行最终删除操作，目前仅作为示例，很可能没有经过测试\n\n\u003e 两者被放在了单独的文件中\n\n可以将全部的行放进需要使用的脚本里并调用\\\n也可以执行`source \"/pathTO/specifyRM_match.sh\"`在*当前* SHELL 载入函数\n\n### 2.1.specifyRM_match\n\n已经写了很多注释了，懒了(´･_･`)\n\n```shell\n# specifyRM_match v1\n# \n# $1 == Match mode\n# $2 == Mode options\n# $3 == Path to be delete\n# \n# return code:\n# 0: matched\n# 1: no match\n# 16: input error\n# \n# mode list:\n# path.basename -- Match full path basename with $2\n# path.prefix -- Match full path prefix with $2\n# path.suffix -- Match full path suffix with $2\n# dir.prefix -- just match directory name prefix with $2\n# dir.suffix -- just match directory name suffix with $2\n```\n\n#### 2.2.1.演示\n\n- 匹配成功\n\n```text\nshell\u003e specifyRM_match path.basename \"2333\" \"/temp/2333\"\nshell\u003e echo $?\n0\n```\n\n- 匹配失败\n\n```text\nshell\u003e specifyRM_match dir.suffix \"/not.mp\" \"/te/mp/2333\"\nshell\u003e echo $?\n1\n```\n\n### 2.2.specifyRM\n\n目前仅作为示例使用\n\n因为参数会直接传进 specifyRM_match 函数里，所以选项和上面一致\\\n如果想要真的**删除/rm**，请取消`rm`的注释\n\n```shell\n# real RM here\n# rm -r \"$3\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourlemonjuice%2Fspecifyrm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsourlemonjuice%2Fspecifyrm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourlemonjuice%2Fspecifyrm/lists"}