Skip to content

Commit 28d9cce

Browse files
committed
Fix creation of colorize.log when debug is not set.
1 parent c484b2d commit 28d9cce

File tree

11 files changed

+57
-32
lines changed

11 files changed

+57
-32
lines changed

Application/SyntaxHighlight.help/Contents/Resources/English.lproj/preferences.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ <h2>Format settings</h2>
138138
The execution of the preprocessor is made inside the same env of the script that handle <code>highlight</code>.
139139
<table>
140140
<tr><th>env</th><th>note</th></tr>
141-
<tr><td>debugHL</td><td>If it is not empty enable the output of the log to the file <code>~/Desktop/colorize.log</code>.</td></tr>
141+
<tr><td>logHL</td><td>If it is not empty set the path of the log file.</td></tr>
142142
<tr><td>targetHL</td><td>Path of the file to colorize.</td></tr>
143143
<tr><td>pathHL</td><td>Path of the highlight executable.</td></tr>
144144
<tr><td>cmdOptsHL</td><td>Array with the arguments passed to the highlight executable.</td></tr>

Application/resources/colorize.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ else
2626
fi
2727

2828
function debug() {
29-
if [ "x$debugHL" != "x" ]; then
30-
echo "`$date +"$date_format"` $@" >> ~/Desktop/colorize.log
29+
if [ "x$logHL" != "x" ]; then
30+
echo "`$date +"$date_format"` $@" >> "$logHL"
3131
fi
3232
}
3333

34-
if [ "x$debugHL" != "x" ]; then
34+
if [ "x$logHL" != "x" ]; then
3535
# Clear the log.
36-
echo "" > ~/Desktop/colorize.log
36+
echo "" > "$logHL"
3737
debug "-------------------------------------------------"
3838
# file to store stderr
39-
err_device=~/Desktop/colorize.log
39+
err_device="$logHL"
4040
else
4141
err_device=/dev/stderr
4242
fi

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Changelog
22
=======
33

4+
5+
### 2.1.1 (48)
6+
New features:
7+
- Application menu item to install/reveal the CLI tool on `/usr/local/bin` folder.
8+
Bugfix:
9+
- Fixed creation of `colorize.log` into the Desktop without debug set.
10+
411
### 2.1.0 (47)
512
New features:
613
- On macOS 12 Monterey adopted the new lightweight API.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,8 @@ The CLI interface uses the same settings as the Quick Look extension, but you ca
414414

415415
The highlighted data is printed to the `stdout` or writed to file if you use the `-o` option.
416416

417+
The command line tool require macOS 10.15.4 or later.
418+
417419
## FAQ
418420

419421
### The Quick Look preview doesn't work

SourceCodeSyntaxHighlight.xcodeproj/project.pbxproj

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,7 +1926,7 @@
19261926
CODE_SIGN_IDENTITY = "-";
19271927
CODE_SIGN_STYLE = Manual;
19281928
COMBINE_HIDPI_IMAGES = YES;
1929-
CURRENT_PROJECT_VERSION = 47;
1929+
CURRENT_PROJECT_VERSION = 48;
19301930
DEVELOPMENT_TEAM = "";
19311931
ENABLE_HARDENED_RUNTIME = YES;
19321932
FRAMEWORK_SEARCH_PATHS = (
@@ -1944,7 +1944,7 @@
19441944
"$(inherited)",
19451945
"\"$(BUILT_PRODUCTS_DIR)/highlight\"",
19461946
);
1947-
MARKETING_VERSION = 2.1.0;
1947+
MARKETING_VERSION = 2.1.1;
19481948
PRODUCT_BUNDLE_IDENTIFIER = org.sbarex.SourceCodeSyntaxHighlight;
19491949
PRODUCT_NAME = "$(TARGET_NAME)";
19501950
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -1962,7 +1962,7 @@
19621962
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
19631963
CODE_SIGN_STYLE = Manual;
19641964
COMBINE_HIDPI_IMAGES = YES;
1965-
CURRENT_PROJECT_VERSION = 47;
1965+
CURRENT_PROJECT_VERSION = 48;
19661966
DEVELOPMENT_TEAM = "";
19671967
ENABLE_HARDENED_RUNTIME = YES;
19681968
FRAMEWORK_SEARCH_PATHS = (
@@ -1980,7 +1980,7 @@
19801980
"$(inherited)",
19811981
"\"$(BUILT_PRODUCTS_DIR)/highlight\"",
19821982
);
1983-
MARKETING_VERSION = 2.1.0;
1983+
MARKETING_VERSION = 2.1.1;
19841984
OTHER_CODE_SIGN_FLAGS = "--timestamp";
19851985
PRODUCT_BUNDLE_IDENTIFIER = org.sbarex.SourceCodeSyntaxHighlight;
19861986
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -1996,7 +1996,7 @@
19961996
CODE_SIGN_ENTITLEMENTS = QLExtension/QLExtension.entitlements;
19971997
CODE_SIGN_IDENTITY = "-";
19981998
CODE_SIGN_STYLE = Manual;
1999-
CURRENT_PROJECT_VERSION = 47;
1999+
CURRENT_PROJECT_VERSION = 48;
20002000
DEVELOPMENT_TEAM = "";
20012001
ENABLE_HARDENED_RUNTIME = YES;
20022002
FRAMEWORK_SEARCH_PATHS = (
@@ -2009,7 +2009,7 @@
20092009
"@executable_path/../Frameworks",
20102010
"@executable_path/../../../../Frameworks",
20112011
);
2012-
MARKETING_VERSION = 2.1.0;
2012+
MARKETING_VERSION = 2.1.1;
20132013
PRODUCT_BUNDLE_IDENTIFIER = org.sbarex.SourceCodeSyntaxHighlight.QuicklookExtension;
20142014
PRODUCT_NAME = "$(TARGET_NAME)";
20152015
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -2025,7 +2025,7 @@
20252025
CODE_SIGN_IDENTITY = "-";
20262026
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
20272027
CODE_SIGN_STYLE = Manual;
2028-
CURRENT_PROJECT_VERSION = 47;
2028+
CURRENT_PROJECT_VERSION = 48;
20292029
DEVELOPMENT_TEAM = "";
20302030
ENABLE_HARDENED_RUNTIME = YES;
20312031
FRAMEWORK_SEARCH_PATHS = (
@@ -2038,7 +2038,7 @@
20382038
"@executable_path/../Frameworks",
20392039
"@executable_path/../../../../Frameworks",
20402040
);
2041-
MARKETING_VERSION = 2.1.0;
2041+
MARKETING_VERSION = 2.1.1;
20422042
OTHER_CODE_SIGN_FLAGS = "--timestamp";
20432043
PRODUCT_BUNDLE_IDENTIFIER = org.sbarex.SourceCodeSyntaxHighlight.QuicklookExtension;
20442044
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -2055,7 +2055,7 @@
20552055
CODE_SIGN_IDENTITY = "-";
20562056
CODE_SIGN_STYLE = Manual;
20572057
COMBINE_HIDPI_IMAGES = YES;
2058-
CURRENT_PROJECT_VERSION = 47;
2058+
CURRENT_PROJECT_VERSION = 48;
20592059
DEVELOPMENT_TEAM = "";
20602060
ENABLE_HARDENED_RUNTIME = YES;
20612061
INFOPLIST_FILE = XPCService/Info.plist;
@@ -2064,7 +2064,7 @@
20642064
"$(LD_RUNPATH_SEARCH_PATHS_$(IS_MACCATALYST)_$(_BOOL_$(SKIP_INSTALL)))",
20652065
);
20662066
LIBRARY_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)/highlight\"";
2067-
MARKETING_VERSION = 2.1.0;
2067+
MARKETING_VERSION = 2.1.1;
20682068
PRODUCT_BUNDLE_IDENTIFIER = org.sbarex.SourceCodeSyntaxHighlight.XPCService;
20692069
PRODUCT_NAME = "$(TARGET_NAME)";
20702070
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -2083,7 +2083,7 @@
20832083
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
20842084
CODE_SIGN_STYLE = Manual;
20852085
COMBINE_HIDPI_IMAGES = YES;
2086-
CURRENT_PROJECT_VERSION = 47;
2086+
CURRENT_PROJECT_VERSION = 48;
20872087
DEVELOPMENT_TEAM = "";
20882088
ENABLE_HARDENED_RUNTIME = YES;
20892089
INFOPLIST_FILE = XPCService/Info.plist;
@@ -2092,7 +2092,7 @@
20922092
"$(LD_RUNPATH_SEARCH_PATHS_$(IS_MACCATALYST)_$(_BOOL_$(SKIP_INSTALL)))",
20932093
);
20942094
LIBRARY_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)/highlight\"";
2095-
MARKETING_VERSION = 2.1.0;
2095+
MARKETING_VERSION = 2.1.1;
20962096
OTHER_CODE_SIGN_FLAGS = "--timestamp";
20972097
PRODUCT_BUNDLE_IDENTIFIER = org.sbarex.SourceCodeSyntaxHighlight.XPCService;
20982098
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -2113,7 +2113,7 @@
21132113
CODE_SIGN_STYLE = Automatic;
21142114
DEVELOPMENT_TEAM = "";
21152115
ENABLE_HARDENED_RUNTIME = YES;
2116-
MACOSX_DEPLOYMENT_TARGET = 11.3;
2116+
MACOSX_DEPLOYMENT_TARGET = 10.15.4;
21172117
PRODUCT_NAME = "$(TARGET_NAME)";
21182118
SWIFT_VERSION = 5.0;
21192119
};
@@ -2128,7 +2128,7 @@
21282128
CODE_SIGN_STYLE = Automatic;
21292129
DEVELOPMENT_TEAM = "";
21302130
ENABLE_HARDENED_RUNTIME = YES;
2131-
MACOSX_DEPLOYMENT_TARGET = 11.3;
2131+
MACOSX_DEPLOYMENT_TARGET = 10.15.4;
21322132
PRODUCT_NAME = "$(TARGET_NAME)";
21332133
SWIFT_VERSION = 5.0;
21342134
};
@@ -2142,7 +2142,7 @@
21422142
CODE_SIGN_IDENTITY = "-";
21432143
CODE_SIGN_STYLE = Manual;
21442144
COMBINE_HIDPI_IMAGES = YES;
2145-
CURRENT_PROJECT_VERSION = 47;
2145+
CURRENT_PROJECT_VERSION = 48;
21462146
DEVELOPMENT_TEAM = "";
21472147
ENABLE_HARDENED_RUNTIME = YES;
21482148
FRAMEWORK_SEARCH_PATHS = (
@@ -2154,7 +2154,7 @@
21542154
"$(inherited)",
21552155
"@loader_path/../../../../Frameworks",
21562156
);
2157-
MARKETING_VERSION = 2.1.0;
2157+
MARKETING_VERSION = 2.1.1;
21582158
PRODUCT_BUNDLE_IDENTIFIER = org.sbarex.SourceCodeSyntaxHighlight.XPCRender;
21592159
PRODUCT_NAME = "$(TARGET_NAME)";
21602160
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -2174,7 +2174,7 @@
21742174
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
21752175
CODE_SIGN_STYLE = Manual;
21762176
COMBINE_HIDPI_IMAGES = YES;
2177-
CURRENT_PROJECT_VERSION = 47;
2177+
CURRENT_PROJECT_VERSION = 48;
21782178
DEVELOPMENT_TEAM = "";
21792179
ENABLE_HARDENED_RUNTIME = YES;
21802180
FRAMEWORK_SEARCH_PATHS = (
@@ -2186,7 +2186,7 @@
21862186
"$(inherited)",
21872187
"@loader_path/../../../../Frameworks",
21882188
);
2189-
MARKETING_VERSION = 2.1.0;
2189+
MARKETING_VERSION = 2.1.1;
21902190
OTHER_CODE_SIGN_FLAGS = "--timestamp";
21912191
PRODUCT_BUNDLE_IDENTIFIER = org.sbarex.SourceCodeSyntaxHighlight.XPCRender;
21922192
PRODUCT_NAME = "$(TARGET_NAME)";

SourceCodeSyntaxHighlight.xcodeproj/xcshareddata/xcschemes/Syntax Highlight.xcscheme

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
buildConfiguration = "Debug"
3535
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
3636
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37-
enableAddressSanitizer = "YES"
3837
launchStyle = "0"
3938
useCustomWorkingDirectory = "NO"
4039
ignoresPersistentStateOnLaunch = "NO"

SyntaxHighlightRenderXPC/ColorizeArgument.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ struct ColorizeArguments {
124124
"convertEOL": custom_settings.convertEOL ? "1" : "",
125125

126126
// Debug
127-
"debugHL": custom_settings.isDebug ? "1" : "",
127+
"logHL": custom_settings.logFile?.path ?? "",
128128
]) { (_, new) in new }
129129

130130
if let _ = env["preprocessorHL"] {

SyntaxHighlightRenderXPC/SCSHBaseXPCService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ class SCSHBaseXPCService: NSObject {
259259
var temporaryThemeFile: URL? = nil
260260

261261
defer {
262-
if custom_settings.isDebug, let logFile = custom_settings.logFile {
262+
if let logFile = custom_settings.logFile {
263263
var log = "";
264264
// Log the custom theme.
265265
if let theme = colorize.inlineTheme, !theme.isEmpty {

SyntaxHighlightRenderXPC/XPCLightRenderService.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ class XPCLightRenderService: SCSHBaseXPCService, XPCLightRenderServiceProtocol {
4040
}
4141

4242
func colorize(url: URL, withReply reply: @escaping (Data, NSDictionary, Error?) -> Void) {
43-
let logFile = URL(fileURLWithPath: NSHomeDirectory(), isDirectory: true).appendingPathComponent("Desktop/colorize.log")
43+
let logFile = self.settings.isDebug ? URL(fileURLWithPath: NSHomeDirectory(), isDirectory: true).appendingPathComponent("Desktop/colorize.log") : URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true).appendingPathComponent("colorize.log")
44+
45+
defer {
46+
if !self.settings.isDebug {
47+
// Remove the temporary log file.
48+
try? FileManager.default.removeItem(at: logFile)
49+
}
50+
}
4451

4552
do {
4653
let r = try type(of: self).colorize(url: url, settings: self.settings, highlightBin: self.getEmbeddedHighlight(), dataDir: self.dataDir, rsrcEsc: self.rsrcEsc, dos2unixBin: self.bundle.path(forResource: "dos2unix", ofType: nil), highlightLanguages: self.highlightLanguages, extraCss: self.getGlobalCSS(), overridingSettings: nil, logFile: logFile, logOs: self.log)

XPCService/SCSHXPCService.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,9 @@ class SCSHXPCService: SCSHBaseXPCService, SCSHXPCServiceProtocol {
252252
}
253253
}
254254

255-
custom_settings.logFile = URL(fileURLWithPath: NSHomeDirectory(), isDirectory: true).appendingPathComponent("Desktop/colorize.log")
255+
if custom_settings.isDebug {
256+
custom_settings.logFile = URL(fileURLWithPath: NSHomeDirectory(), isDirectory: true).appendingPathComponent("Desktop/colorize.log")
257+
}
256258

257259
do {
258260
var colorize = try ColorizeArguments(highlight: self.getEmbeddedHighlight(), dataDir: self.dataDir, url: url, custom_settings: custom_settings, extraCss: self.getGlobalCSS())
@@ -304,7 +306,9 @@ class SCSHXPCService: SCSHBaseXPCService, SCSHXPCServiceProtocol {
304306
custom_settings = SettingsRendering(settings: self.settings.toDictionary())
305307
}
306308
}
307-
custom_settings.logFile = URL(fileURLWithPath: NSHomeDirectory(), isDirectory: true).appendingPathComponent("Desktop/colorize.log")
309+
if custom_settings.isDebug {
310+
custom_settings.logFile = URL(fileURLWithPath: NSHomeDirectory(), isDirectory: true).appendingPathComponent("Desktop/colorize.log")
311+
}
308312

309313
custom_settings.format = .html
310314
do {
@@ -364,7 +368,9 @@ class SCSHXPCService: SCSHBaseXPCService, SCSHXPCServiceProtocol {
364368
custom_settings = SettingsRendering(settings: self.settings.toDictionary())
365369
}
366370
}
367-
custom_settings.logFile = URL(fileURLWithPath: NSHomeDirectory(), isDirectory: true).appendingPathComponent("Desktop/colorize.log")
371+
if custom_settings.isDebug {
372+
custom_settings.logFile = URL(fileURLWithPath: NSHomeDirectory(), isDirectory: true).appendingPathComponent("Desktop/colorize.log")
373+
}
368374

369375
custom_settings.format = .rtf
370376
do {

0 commit comments

Comments
 (0)