diff --git a/Makefile b/Makefile index bae3b09..836f7df 100644 --- a/Makefile +++ b/Makefile @@ -61,6 +61,7 @@ NIM_OPTIONS = \ --putenv:'PROG_LOCALSTATEDIR'="${LOCALSTATEDIR}" \ --putenv:'PROG_SYSCONFDIR'="${SYSCONFDIR}" \ -d:'${NIM_TARGET}' \ +# -d:nimPreviewSlimSystem \ --opt:'${NIM_OPTIMIZE}' \ --hint'[Conf]':off \ --hint'[Processing]':off \ diff --git a/lib/install.nim b/lib/install.nim index 2a89ade..9ac38cf 100644 --- a/lib/install.nim +++ b/lib/install.nim @@ -1,5 +1,6 @@ import os, posix, sequtils, strutils, sugar +when not declared(system.stdout): import std/syncio proc splitCommands(params: seq[string], index: int, res: seq[seq[string]]): seq[seq[string]] = if index < params.len: @@ -68,7 +69,7 @@ proc handleInstall*(params: seq[string]): int = let dest = destination & "/" & name copyFile(pkg.file, dest) discard chown(cstring(dest), (Uid) uid, (Gid) gid) - except: + except CatchableError: discard let asexplicit = install.filter(p => p.mode == "explicit").map(p => p.name) diff --git a/src/args.nim b/src/args.nim index deabeff..a465b7f 100644 --- a/src/args.nim +++ b/src/args.nim @@ -1,6 +1,7 @@ import options, os, posix, sequtils, sets, strutils, sugar, utils +when not declared(system.stdout): import std/syncio type ArgumentType* {.pure.} = enum @@ -26,7 +27,7 @@ iterator readLines(): string = try: while true: yield readLine(stdin) - except: + except CatchableError: discard iterator splitSingle(valueFull: string, optionsWithParameter: HashSet[OptionKey], diff --git a/src/aur.nim b/src/aur.nim index 12f6253..78afae5 100644 --- a/src/aur.nim +++ b/src/aur.nim @@ -108,7 +108,7 @@ proc getRpcPackageInfosInternal(pkgs: seq[string], repo: string, useTimeout: boo (@[], some(getCurrentException().msg)) except JsonParsingError: (@[], some(tr"failed to parse server response")) - except: + except CatchableError: (@[], some(getCurrentException().msg)) proc getRpcPackageInfos*(pkgs: seq[string], repo: string, useTimeout: bool, configColor: bool): diff --git a/src/common.nim b/src/common.nim index da36c0d..81badb3 100644 --- a/src/common.nim +++ b/src/common.nim @@ -2,6 +2,7 @@ import options, os, osproc, posix, sequtils, sets, strutils, sugar, tables, args, config, format, lists, package, pacman, utils, "wrapper/alpm" +when not declared(system.stdout): import std/syncio type CacheKind* {.pure.} = enum @@ -331,7 +332,7 @@ proc createDirRecursive(dir: string, chownUser: Option[User], mkTmp: bool): bool if chownUser.isSome and (not exists or index == segments.len - 1): discard chown(cstring(path), (Uid) chownUser.unsafeGet.uid, (Gid) chownUser.unsafeGet.gid) createDirIndex(index + 1) - except: + except CatchableError: false else: true @@ -882,7 +883,7 @@ proc cloneAurReposWithPackageInfos*(config: Config, rpcInfos: seq[RpcPackageInfo else: let srcInfos = try: readFile(repoPath & "/.SRCINFO") - except: + except CatchableError: "" let addPkgInfos = parseSrcInfo(config.aurRepo, srcInfos, config.common.arch, diff --git a/src/config.nim b/src/config.nim index 598b488..a5fab96 100644 --- a/src/config.nim +++ b/src/config.nim @@ -1,6 +1,7 @@ import std/[options, posix, re, sequtils, sets, strutils, sugar, tables], utils +when not declared(system.stdout): import std/syncio type ColorMode* {.pure.} = enum diff --git a/src/feature/syncinstall.nim b/src/feature/syncinstall.nim index a728851..eaeafe9 100644 --- a/src/feature/syncinstall.nim +++ b/src/feature/syncinstall.nim @@ -3,6 +3,7 @@ import "../args", "../aur", "../config", "../common", "../format", "../lists", "../package", "../pacman", "../utils", "../wrapper/alpm" +when not declared(system.stdout): import std/syncio type Installed = tuple[ @@ -444,7 +445,7 @@ proc buildLoop(config: Config, pkgInfos: seq[PackageInfo], skipDeps: bool, finally: file.close() true - except: + except CatchableError: discard unlink(cstring(workConfFile)) false @@ -625,7 +626,7 @@ proc installGroupFromSources(config: Config, commonArgs: seq[Argument], if clear or not (pair.file in installFiles): try: removeFile(pair.file) - except: + except CatchableError: discard if not clear: diff --git a/src/format.nim b/src/format.nim index cf4b9db..60c550d 100644 --- a/src/format.nim +++ b/src/format.nim @@ -1,6 +1,7 @@ import std/[macros, options, posix, sequtils, strutils, sugar, times, unicode, terminal], utils +when not declared(system.stdout): import std/syncio type PackageLineFormat* = tuple[ diff --git a/src/main.nim b/src/main.nim index 3960d59..c6745d8 100644 --- a/src/main.nim +++ b/src/main.nim @@ -1,6 +1,7 @@ import options, os, posix, re, sequtils, strutils, sugar, args, config, format, pacman, utils +when not declared(system.stdout): import std/syncio import "feature/localquery", diff --git a/src/package.nim b/src/package.nim index e48b01f..5c2bf5c 100644 --- a/src/package.nim +++ b/src/package.nim @@ -1,6 +1,7 @@ import options, os, re, sequtils, sets, strutils, sugar, tables, utils, "wrapper/alpm" +when not declared(system.stdout): import std/syncio type ConstraintOperation* {.pure.} = enum @@ -130,7 +131,7 @@ static: try: if m2[x2] != x1: raise newException(CatchableError, "") - except: + except CatchableError: raise newException(CatchableError, "Invalid url <> bareName links") testBareNamesAndUrls(bareNameToUrl, urlToBareName) diff --git a/src/pacman.nim b/src/pacman.nim index c37a54c..2910a90 100644 --- a/src/pacman.nim +++ b/src/pacman.nim @@ -1,6 +1,7 @@ import macros, options, posix, sequtils, sets, strutils, sugar, tables, args, config, utils +when not declared(system.stdout): import std/syncio type OpGroup* {.pure.} = enum @@ -438,7 +439,7 @@ proc obtainPacmanConfig*(args: seq[Argument]): PacmanConfig = let line = file.readLine() if line.len > 10 and line[0 .. 9] == "keyserver ": pgpKeyserver = some(line[9 .. ^1].strip) - except: + except CatchableError: discard finally: file.close() diff --git a/src/utils.nim b/src/utils.nim index eccde3b..6f8b8d1 100644 --- a/src/utils.nim +++ b/src/utils.nim @@ -251,9 +251,12 @@ let initialUser* = try: else: none(string) - let uid = uidString.get.parseInt - if uid == 0 or currentUser.uid != 0: none(User) else: some(getUser(uid)) -except: + if uidString.isSome: + let uid = uidString.get.parseInt + if uid == 0 or currentUser.uid != 0: none(User) else: some(getUser(uid)) + else: + none(User) +except CatchableError: none(User) proc canDropPrivileges*(): bool = @@ -303,7 +306,7 @@ proc execRedirect*(args: varargs[string]): int = argSeq.delete(0) try: p = startProcess(command = args[0], args = argSeq, env = envs, options = {poStdErrToStdOut, poUsePath}) - except: + except CatchableError: echo "Error: " & getCurrentExceptionMsg() return -1 var outp = outputStream(p) @@ -421,7 +424,7 @@ proc toString*[T](arr: array[T, char], length: Option[int]): string = proc removeDirQuiet*(s: string) = try: removeDir(s) - except: + except CatchableError: discard proc removeTmpDirQuiet*(s: string) = @@ -432,7 +435,7 @@ proc removeTmpDirQuiet*(s: string) = path = s try: removeDir(path) - except: + except CatchableError: discard const bashSpecialCharacters = " \t\"'`()[]{}#&|;!\\*~<>?"