diff options
author | Ted Trask <ttrask01@yahoo.com> | 2009-01-24 16:52:21 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2009-01-24 16:52:21 +0000 |
commit | e5034a6d32d2974ed131de0b54c06b7bb8c440c0 (patch) | |
tree | b9cc47dbbe4120e6039d1134e4ed5315116b0723 | |
parent | baef7de9972477efffef99b74711e85e888d81c6 (diff) | |
download | acf-alpine-baselayout-e5034a6d32d2974ed131de0b54c06b7bb8c440c0.tar.bz2 acf-alpine-baselayout-e5034a6d32d2974ed131de0b54c06b7bb8c440c0.tar.xz |
Started process of removing as many io.popen calls as possible. Not complete.
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@1695 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r-- | skins-model.lua | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/skins-model.lua b/skins-model.lua index 620e7a7..d4f7c34 100644 --- a/skins-model.lua +++ b/skins-model.lua @@ -1,14 +1,19 @@ -- acf model for displaying logfiles recusivly module (..., package.seeall) +require("fs") require("format") local function set_skins(skin) - local cmd = "/bin/sed -i 's/skin=.*/skin=" .. format.escapespecialcharacters(skin) .. "/' /etc/acf/acf.conf" - local f, errtxt = io.popen(cmd) - local cmdoutput = f:read("*a") - if cmdoutput == "" then cmdoutput = "New skin selected" end - f:close() + local conffile = "/etc/acf/acf.conf" + local content = "\n"..(fs.read_file(conffile) or "") + local count + content,count = string.gsub(content, "\n%s*skin%s*=[^\n]*", "\nskin="..format.escapespecialcharacters(skin)) + if count == 0 then + content = "\nskin="..format.escapespecialcharacters(skin)..content + end + fs.write_file(conffile, string.sub(content,2)) + local cmdoutput = "New skin selected" return cmdoutput, errtxt end |