Friday, September 18, 2020

Unwanted Dollar Sign in Bash Script

The script that I used ran fine for various flavors of Linux for a long time. But somehow, it produced unwanted dollar sign on Ubuntu 18.04, so my hours of troubleshooting starts.

Problem

The simplest one I can say is I use echo with tab and variables and piped that to awk through AWS Systems Manager. It is similar to the following:

v='variable'
TAB=$'\t'
echo "${v}${TAB}" | awk '{print $0}'

In many flavors of Linux other than Ubuntu 18.04, even in Ubuntu 16.04, it produced the expected result:

variable

However, in Ubuntu 18.04, it ends the result with an extra dollar sign:

variable$

At first, I thought it marks end of line or the typical \0 (NUL character) that marks end of string, so I tried various ways to remove it such as using tr, gsub, etc. But none of them works.

Solution

Eventually, I found out that the dollar sign comes from the TAB variable. To solve it, I have to replace the above with:

echo -e "${v}\t"

Tuesday, September 15, 2020

Searching Files by DateModified in File Explorer in Windows

I was in the middle of some project files restructuring and part of the process is making a back up of my files. When all is done, I went back to my back up folder to find files that I modified a day before.

Problem

I know there has to be a way to do that, but it is not immediately obvious. But the following article was helpful to me.

https://www.howtogeek.com/243511/how-to-search-for-files-from-a-certain-date-range-in-windows-8-and-10

I opted for the UI solution, that is to use the Search tab. However, I can't find the search tab in File explorer, so I decided to go the harder route, to type into the search box.

Solution

I managed to file my files by typing the following in the search box:

datemodified:<start_date>..<end_date>

For example:

datemodified:9/14/2020..9/15/2020

modified: instead of datemodified: works too. Also, the search tab finally shows after I got my search result.

Friday, September 11, 2020

Signing Certificate is None in Xcode

Xcode has this capability to manage certificates, app ID and provisioning profile which makes is very convenient. However, this time, I would like to manage my own.

Problem

I manage to get Xcode to recognize the provisioning profile that I have created in developer.apple.com. However, under .xcodeproj (project file) > Signing & Capabilities > Signing Certificate, the value is none. It also comes with an error that it the provisioning profile is not associated with its own developer certificate. I have made sure that the certificate associated with the provisioning profile is stored in my Keychain, but it seems like Xcode is still trying to use a different certificate for signing.

Solution

My guess was right, I went to .xcodeproj (project file) > Build Settings > Code Signing Identity and found out that it is set to iOS Developer under "Automatic" section. Switching it to the right (associated with provisioning profile) certificate on the Keychain solves the issue.

Xcode CodeSign Incorrectly States Password is Incorrect

I was trying to create an archive in Xcode to prepare the app for testing. It requires a code signing certificate and Xcode tried to reach out to Keychain to obtain it, so it prompted me for a password to my Keychain.

Problem

My first thought is since the Keychain lives in my Mac, it has to be my Mac's password, so I entered it and it failed. I re-checked the characters, re-entered and it still failed. That is odd considering I did that before without issue.

Solution

I found out that my Keychain Access app was still active. I have to quit the app and then it proceeds properly. So, the solution is quit the Keychain Access app before entering password for signing.